Interface: NodeRecords
Defined in: packages/core/src/node/types.ts:570
Methods
addFile()
addFile(
spaceId,
bytes,
about
): Promise<FileRef>;Defined in: packages/core/src/node/types.ts:626
Seals and keeps a file, giving the reference to put in a body (spec 05 §16.6)
Parameters
| Parameter | Type |
|---|---|
spaceId | string |
bytes | Uint8Array |
about | { mime: string; name?: string; } |
about.mime | string |
about.name? | string |
Returns
Promise<FileRef>
can()
can(
spaceId,
action,
target
): Promise<boolean>;Defined in: packages/core/src/node/types.ts:624
Whether this account may create in a collection, or edit / delete a record; target names it
Parameters
| Parameter | Type |
|---|---|
spaceId | string |
action | "delete" | "create" | "edit" |
target | string |
Returns
Promise<boolean>
contracts()
contracts(
spaceId,
key,
version?
): Promise<RecordContracts | null>;Defined in: packages/core/src/node/types.ts:582
How a record's newest standing version, or the one named, fares under its
collection's contract: { version, passes, reason?, pending?, unjudged? }.
passes is false with the failing condition's else as reason, and null
when the collection has no contract, the version waits on one it cites
(pending), or this library can't judge it (unjudged, with why)
Parameters
| Parameter | Type |
|---|---|
spaceId | string |
key | string |
version? | string |
Returns
Promise<RecordContracts | null>
delete()
delete(spaceId, key): Promise<void>;Defined in: packages/core/src/node/types.ts:620
Deletes a record everywhere, by writing a version marked deleted
Parameters
| Parameter | Type |
|---|---|
spaceId | string |
key | string |
Returns
Promise<void>
get()
get<T>(spaceId, key): Promise<NodeRecord<T> | null>;Defined in: packages/core/src/node/types.ts:574
A record's current version, or null when there is none or it was deleted
Type Parameters
| Type Parameter | Default type |
|---|---|
T | unknown |
Parameters
| Parameter | Type |
|---|---|
spaceId | string |
key | string |
Returns
Promise<NodeRecord<T> | null>
history()
history<T>(spaceId, key): Promise<readonly NodeRecord<T>[]>;Defined in: packages/core/src/node/types.ts:622
The versions of a record kept whole here, newest first: the current one, or every one in a collection defined with history: 'all'
Type Parameters
| Type Parameter | Default type |
|---|---|
T | unknown |
Parameters
| Parameter | Type |
|---|---|
spaceId | string |
key | string |
Returns
Promise<readonly NodeRecord<T>[]>
keyFor()
keyFor(
spaceId,
name,
account?
): Promise<string>;Defined in: packages/core/src/node/types.ts:584
The key name has in an account's namespace (this one's by default): where put(…, { key: name }) writes
Parameters
| Parameter | Type |
|---|---|
spaceId | string |
name | string |
account? | string |
Returns
Promise<string>
linked()
linked<T>(
spaceId,
key,
options?
): Promise<readonly NodeRecord<T>[]>;Defined in: packages/core/src/node/types.ts:614
The records whose current version points at this one, optionally by role or collection
Type Parameters
| Type Parameter | Default type |
|---|---|
T | unknown |
Parameters
| Parameter | Type |
|---|---|
spaceId | string |
key | string |
options? | { collection?: string; rel?: string; } |
options.collection? | string |
options.rel? | string |
Returns
Promise<readonly NodeRecord<T>[]>
list()
list<T>(spaceId, options?): Promise<readonly NodeRecord<T>[]>;Defined in: packages/core/src/node/types.ts:572
Current versions, oldest record first; deleted records only with includeDeleted
Type Parameters
| Type Parameter | Default type |
|---|---|
T | unknown |
Parameters
| Parameter | Type |
|---|---|
spaceId | string |
options? | ListOptions |
Returns
Promise<readonly NodeRecord<T>[]>
onePerKey()
onePerKey(
spaceId,
collection,
body,
options?
): Promise<string | null>;Defined in: packages/core/src/node/types.ts:586
The key a record with this body has under its collection's onePer; null when there is none
Parameters
| Parameter | Type |
|---|---|
spaceId | string |
collection | string |
body | unknown |
options? | { account?: string; links?: readonly Link[]; } |
options.account? | string |
options.links? | readonly Link[] |
Returns
Promise<string | null>
put()
Call Signature
put<T>(
spaceId,
collection,
body,
options?
): Promise<NodeRecord<T>>;Defined in: packages/core/src/node/types.ts:593
Creates a record under a fresh key, or key in this account's namespace. Writing a deleted key brings it back.
Type Parameters
| Type Parameter | Default type |
|---|---|
T | unknown |
Parameters
| Parameter | Type |
|---|---|
spaceId | string |
collection | string |
body | T |
options? | { key?: string; links?: readonly Link[]; } |
options.key? | string |
options.links? | readonly Link[] |
Returns
Promise<NodeRecord<T>>
Call Signature
put<C>(
spaceId,
collection,
body,
options?
): Promise<NodeRecord<BodyOf<C>>>;Defined in: packages/core/src/node/types.ts:600
The same, typed by the collection's definition
Type Parameters
| Type Parameter |
|---|
C extends object |
Parameters
| Parameter | Type |
|---|---|
spaceId | string |
collection | C |
body | BodyOf<C> |
options? | { key?: string; links?: readonly Link[]; } |
options.key? | string |
options.links? | readonly Link[] |
Returns
Promise<NodeRecord<BodyOf<C>>>
query()
query<C, I>(spaceId, query): Promise<ResultFor<C, I>>;Defined in: packages/core/src/node/types.ts:637
Records matching a query, typed when it names a collection by its definition.
Type Parameters
| Type Parameter | Default type |
|---|---|
C extends CollectionRef | - |
I extends Readonly<Record<string, Include>> | undefined | undefined |
Parameters
| Parameter | Type |
|---|---|
spaceId | string |
query | Query<C, I> |
Returns
Promise<ResultFor<C, I>>
Throws
When the query is malformed, saying what to fix
readFile()
readFile(spaceId, ref): Promise<Uint8Array<ArrayBufferLike>>;Defined in: packages/core/src/node/types.ts:632
The bytes of a file a body refers to: held here, or fetched from peers or mirrors, checking every chunk. While nobody has it, it waits and asks again.
Parameters
| Parameter | Type |
|---|---|
spaceId | string |
ref | FileRef |
Returns
Promise<Uint8Array<ArrayBufferLike>>
Throws
When no record here names it, when it won't open as named, or when the space closes
update()
update<T>(
spaceId,
key,
body,
options?
): Promise<NodeRecord<T>>;Defined in: packages/core/src/node/types.ts:607
Writes the record's next version; links carry over unless given
Type Parameters
| Type Parameter | Default type |
|---|---|
T | unknown |
Parameters
| Parameter | Type |
|---|---|
spaceId | string |
key | string |
body | T |
options? | { links?: readonly Link[]; } |
options.links? | readonly Link[] |
Returns
Promise<NodeRecord<T>>
watch()
watch<C, I>(
spaceId,
query,
onResult,
onError?
): () => void;Defined in: packages/core/src/node/types.ts:642
Runs a query now and whenever the space's records change; returns a function that stops it
Type Parameters
| Type Parameter | Default type |
|---|---|
C extends CollectionRef | - |
I extends Readonly<Record<string, Include>> | undefined | undefined |
Parameters
| Parameter | Type |
|---|---|
spaceId | string |
query | Query<C, I> |
onResult | (result) => void |
onError? | (error) => void |
Returns
() => void