JS Collection

Class: Collection#

Collection.Collection

Properties#

id#

• id: string


metadata#

• metadata: CollectionMetadata


name#

• name: string

Methods#

add#

â–¸ add(params): Promise<void>

Add items to the collection

Parameters#

NameTypeDescription
paramsAddRecordsParamsThe parameters for the query.

Returns#

Promise<void>

  • The response from the API. True if successful.

Example

typescript


count#

â–¸ count(): Promise<number>

Count the number of items in the collection

Returns#

Promise<number>

  • The number of items in the collection.

Example

typescript


delete#

â–¸ delete(params?): Promise<string[]>

Deletes items from the collection.

Parameters#

NameTypeDescription
paramsDeleteParamsThe parameters for deleting items from the collection.

Returns#

Promise<string[]>

A promise that resolves to the IDs of the deleted items.

Throws

If there is an issue deleting items from the collection.

Example

typescript


get#

â–¸ get(params?): Promise<MultiGetResponse>

Get items from the collection

Parameters#

NameTypeDescription
paramsBaseGetParamsThe parameters for the query.

Returns#

Promise<MultiGetResponse>

  • The response from the server.

Example

typescript


modify#

â–¸ modify(params): Promise<CollectionParams>

Modify the collection name or metadata

Parameters#

NameTypeDescription
paramsObjectThe parameters for the query.
params.metadata?CollectionMetadataOptional new metadata for the collection.
params.name?stringOptional new name for the collection.

Returns#

Promise<CollectionParams>

  • The response from the API.

Example

typescript


peek#

â–¸ peek(params?): Promise<MultiGetResponse>

Peek inside the collection

Parameters#

NameTypeDescription
paramsPeekParamsThe parameters for the query.

Returns#

Promise<MultiGetResponse>

A promise that resolves to the query results.

Throws

If there is an issue executing the query.

Example

typescript


query#

â–¸ query(params): Promise<MultiQueryResponse>

Performs a query on the collection using the specified parameters.

Parameters#

NameTypeDescription
paramsQueryRecordsParamsThe parameters for the query.

Returns#

Promise<MultiQueryResponse>

A promise that resolves to the query results.

Throws

If there is an issue executing the query.

Example

ts

Example

javascript


update#

â–¸ update(params): Promise<void>

Update items in the collection

Parameters#

NameTypeDescription
paramsUpdateRecordsParamsThe parameters for the query.

Returns#

Promise<void>

Example

typescript


upsert#

â–¸ upsert(params): Promise<void>

Upsert items to the collection

Parameters#

NameTypeDescription
paramsAddRecordsParamsThe parameters for the query.

Returns#

Promise<void>

Example

typescript