minca
ApiCoreInterfaces

Interface: NodeRecords

Defined in: packages/core/src/node/types.ts:565

Methods

addFile()

addFile(
   spaceId, 
   bytes, 
   about
): Promise<FileRef>;

Defined in: packages/core/src/node/types.ts:621

Seals and keeps a file, giving the reference to put in a body (spec 05 §16.6)

Parameters

ParameterType
spaceIdstring
bytesUint8Array
about{ mime: string; name?: string; }
about.mimestring
about.name?string

Returns

Promise<FileRef>


can()

can(
   spaceId, 
   action, 
   target
): Promise<boolean>;

Defined in: packages/core/src/node/types.ts:619

Whether this account may create in a collection, or edit / delete a record; target names it

Parameters

ParameterType
spaceIdstring
action"delete" | "create" | "edit"
targetstring

Returns

Promise<boolean>


contracts()

contracts(
   spaceId, 
   key, 
   version?
): Promise<RecordContracts | null>;

Defined in: packages/core/src/node/types.ts:577

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

ParameterType
spaceIdstring
keystring
version?string

Returns

Promise<RecordContracts | null>


delete()

delete(spaceId, key): Promise<void>;

Defined in: packages/core/src/node/types.ts:615

Deletes a record everywhere, by writing a version marked deleted

Parameters

ParameterType
spaceIdstring
keystring

Returns

Promise<void>


get()

get<T>(spaceId, key): Promise<NodeRecord<T> | null>;

Defined in: packages/core/src/node/types.ts:569

A record's current version, or null when there is none or it was deleted

Type Parameters

Type ParameterDefault type
Tunknown

Parameters

ParameterType
spaceIdstring
keystring

Returns

Promise<NodeRecord<T> | null>


history()

history<T>(spaceId, key): Promise<readonly NodeRecord<T>[]>;

Defined in: packages/core/src/node/types.ts:617

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 ParameterDefault type
Tunknown

Parameters

ParameterType
spaceIdstring
keystring

Returns

Promise<readonly NodeRecord<T>[]>


keyFor()

keyFor(
   spaceId, 
   name, 
   account?
): Promise<string>;

Defined in: packages/core/src/node/types.ts:579

The key name has in an account's namespace (this one's by default): where put(…, { key: name }) writes

Parameters

ParameterType
spaceIdstring
namestring
account?string

Returns

Promise<string>


linked()

linked<T>(
   spaceId, 
   key, 
   options?
): Promise<readonly NodeRecord<T>[]>;

Defined in: packages/core/src/node/types.ts:609

The records whose current version points at this one, optionally by role or collection

Type Parameters

Type ParameterDefault type
Tunknown

Parameters

ParameterType
spaceIdstring
keystring
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:567

Current versions, oldest record first; deleted records only with includeDeleted

Type Parameters

Type ParameterDefault type
Tunknown

Parameters

ParameterType
spaceIdstring
options?ListOptions

Returns

Promise<readonly NodeRecord<T>[]>


onePerKey()

onePerKey(
   spaceId, 
   collection, 
   body, 
   options?
): Promise<string | null>;

Defined in: packages/core/src/node/types.ts:581

The key a record with this body has under its collection's onePer; null when there is none

Parameters

ParameterType
spaceIdstring
collectionstring
bodyunknown
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:588

Creates a record under a fresh key, or key in this account's namespace. Writing a deleted key brings it back.

Type Parameters
Type ParameterDefault type
Tunknown
Parameters
ParameterType
spaceIdstring
collectionstring
bodyT
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:595

The same, typed by the collection's definition

Type Parameters
Type Parameter
C extends object
Parameters
ParameterType
spaceIdstring
collectionC
bodyBodyOf<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:632

Records matching a query, typed when it names a collection by its definition.

Type Parameters

Type ParameterDefault type
C extends CollectionRef-
I extends Readonly<Record<string, Include>> | undefinedundefined

Parameters

ParameterType
spaceIdstring
queryQuery<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:627

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

ParameterType
spaceIdstring
refFileRef

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:602

Writes the record's next version; links carry over unless given

Type Parameters

Type ParameterDefault type
Tunknown

Parameters

ParameterType
spaceIdstring
keystring
bodyT
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:637

Runs a query now and whenever the space's records change; returns a function that stops it

Type Parameters

Type ParameterDefault type
C extends CollectionRef-
I extends Readonly<Record<string, Include>> | undefinedundefined

Parameters

ParameterType
spaceIdstring
queryQuery<C, I>
onResult(result) => void
onError?(error) => void

Returns

() => void

On this page