Arex.Record (arex v0.1.0)

Copy Markdown View Source

Document-style CRUD helpers with tenant and scope awareness.

Arex.Record is the main high-level API for working with ordinary ArcadeDB records. It stamps boundaries on writes, filters reads by boundaries when provided, and returns normalized errors for missing or ambiguous results.

Input maps may use atom or string keys for ordinary fields. The module keeps common CRUD workflows, boundary enforcement, and RID-based operations out of handwritten SQL so application code can stay focused on domain logic.

Reach for Arex.Record when you want:

  • inserts and updates decided from record shape
  • where:-based upserts
  • boundary-aware reads and deletes
  • batch persistence in one SQLScript transaction

This is the module that most application code should start with before dropping to raw Arex.Query or Arex.Command.

Summary

Functions

Extracts @cat from a record map.

Fetches a record by RID and enforces the active tenant and scope boundary.

Fetches many records by RID, returning nil for missing or out-of-boundary rows.

Finds records by filters and the required type option.

Returns one matching record or nil, failing on ambiguous matches.

Fetches one property from a record identified by RID.

Returns whether at least one record matches the provided filters.

Merges attributes into an existing record and re-fetches the result.

Inserts a new record or updates an existing one.

Persists many records in a single SQLScript transaction.

Inserts a copy of a record while ignoring any existing @rid.

Removes a value from a list property when present.

Appends a value to a list property when it is not already present.

Replaces a record's content while preserving its current boundary fields.

Extracts @rid from a record map.

Sets a boolean property to false.

Sets a boolean property to true.

Extracts @type from a record map.

Updates one mutable property and re-fetches the record.

Upserts one record by type and where: filter.

Deletes a record map that contains @rid.

Deletes a record by RID.

Functions

category(record)

Extracts @cat from a record map.

fetch(rid, opts \\ [])

Fetches a record by RID and enforces the active tenant and scope boundary.

fetch_multi(rids, opts \\ [])

Fetches many records by RID, returning nil for missing or out-of-boundary rows.

This keeps the returned list aligned with the input RID order.

get(filters, opts \\ [])

Finds records by filters and the required type option.

Active tenant and scope values are appended automatically to the filter predicate when present.

get_one(filters, opts \\ [])

Returns one matching record or nil, failing on ambiguous matches.

get_property(rid, property, opts \\ [])

Fetches one property from a record identified by RID.

is_there?(filters, opts \\ [])

Returns whether at least one record matches the provided filters.

This is a convenience wrapper over get/2 with limit: 1.

merge(rid, attrs, opts \\ [])

Merges attributes into an existing record and re-fetches the result.

persist(record, opts \\ [])

Inserts a new record or updates an existing one.

Records without @rid are inserted. Records with @rid are updated by RID.

persist_multi(records, opts \\ [])

Persists many records in a single SQLScript transaction.

The batch succeeds or fails atomically. Records with @rid are updated and records without @rid are inserted.

persist_new(record, opts \\ [])

Inserts a copy of a record while ignoring any existing @rid.

pop(rid, property, value, opts \\ [])

Removes a value from a list property when present.

push(rid, property, value, opts \\ [])

Appends a value to a list property when it is not already present.

replace(rid, attrs, opts \\ [])

Replaces a record's content while preserving its current boundary fields.

rid(record)

Extracts @rid from a record map.

switch_off(rid, property, opts \\ [])

Sets a boolean property to false.

switch_on(rid, property, opts \\ [])

Sets a boolean property to true.

type(record)

Extracts @type from a record map.

update_property(rid, property, value, opts \\ [])

Updates one mutable property and re-fetches the record.

upsert(type, attrs, opts \\ [])

Upserts one record by type and where: filter.

The where: clause must be non-empty, and the operation fails when more than one row matches. Boundary fields from opts remain authoritative and are stamped onto the stored record.

vaporize(record, opts \\ [])

Deletes a record map that contains @rid.

vaporize_by_id(rid, opts \\ [])

Deletes a record by RID.