Class: Collection<T>

Defined in: ridb_core.d.ts:162

Collection is a class that represents a collection of documents in a database.

Type Parameters

T

T extends SchemaType

A schema type defining the structure of the documents in the collection.

Constructors

Constructor

typescript
1
new Collection<T>(): Collection<T>

Returns

Collection<T>

Methods

count()

typescript
1
count(query, options?): Promise<number>

Defined in: ridb_core.d.ts:174

count all documents in the collection.

Parameters

query

QueryType<T>

options?

QueryOptions

Returns

Promise<number>

A promise that resolves to an array of documents.


create()

typescript
1
create(document): Promise<Doc<T>>

Defined in: ridb_core.d.ts:195

Creates a new document in the collection.

Parameters

document

CreateDoc<T>

The document to create.

Returns

Promise<Doc<T>>

A promise that resolves to the created document.


delete()

typescript
1
delete(id): Promise<void>

Defined in: ridb_core.d.ts:202

Deletes a document in the collection by its ID.

Parameters

id

string

The ID of the document to delete.

Returns

Promise<void>

A promise that resolves when the deletion is complete.


find()

typescript
1
find(query, options?): Promise<Doc<T>[]>

Defined in: ridb_core.d.ts:168

Finds all documents in the collection.

Parameters

query

QueryType<T>

options?

QueryOptions

Returns

Promise<Doc<T>[]>

A promise that resolves to an array of documents.


findById()

typescript
1
findById(id): Promise<Doc<T>>

Defined in: ridb_core.d.ts:181

Finds a single document in the collection by its ID.

Parameters

id

string

The ID of the document to find.

Returns

Promise<Doc<T>>

A promise that resolves to the found document.


update()

typescript
1
update(document): Promise<void>

Defined in: ridb_core.d.ts:188

Updates a document in the collection by its ID.

Parameters

document

Partial<Doc<T>>

A partial document containing the fields to update.

Returns

Promise<void>

A promise that resolves when the update is complete.