Skip to content

Collection

Defined in: packages/client/src/collection.ts:32

A collection: one table of the database. Methods mirror the MongoDB Node.js driver.

Writes are atomic per call (insertMany, updateMany and bulkWrite apply all or nothing) and acknowledged once safely logged; they reach Google Drive within about 2 seconds.

TSchema extends object = Document

new Collection<TSchema>(http, collectionName, onStream?): Collection<TSchema>

Defined in: packages/client/src/collection.ts:33

HttpClient

string

The collection’s API name.

(stream) => void

Collection<TSchema>

readonly collectionName: string

Defined in: packages/client/src/collection.ts:36

The collection’s API name.

aggregate<T>(pipeline, options?): ArrayCursor<T>

Defined in: packages/client/src/collection.ts:78

Run an aggregation pipeline ($match, $group, $lookup, $sort…). $out and $merge aren’t supported.

T = Document

Document[]

ReadOptions = {}

ArrayCursor<T>


bulkWrite(operations, options?): Promise<BulkWriteResult>

Defined in: packages/client/src/collection.ts:165

Several writes applied together: if one fails, none is applied. Up to 1,000 operations.

AnyBulkWriteOperation<TSchema>[]

WriteOptions = {}

Promise<BulkWriteResult>


countDocuments(filter?, options?): Promise<number>

Defined in: packages/client/src/collection.ts:57

Filter<TSchema> = {}

ReadOptions = {}

Promise<number>


createIndex(keys, options?): Promise<string>

Defined in: packages/client/src/collection.ts:188

createIndex({ email: 1 }, { unique: true }) makes the field unique (enforced on every write). Other indexes are accepted for driver compatibility and do nothing: queries are always answered from memory.

Record<string, 1 | -1>

WriteOptions & object = {}

Promise<string>


deleteMany(filter, options?): Promise<DeleteResult>

Defined in: packages/client/src/collection.ts:130

Filter<TSchema>

WriteOptions = {}

Promise<DeleteResult>


deleteOne(filter, options?): Promise<DeleteResult>

Defined in: packages/client/src/collection.ts:126

Filter<TSchema>

WriteOptions = {}

Promise<DeleteResult>


distinct(key, filter?, options?): Promise<unknown[]>

Defined in: packages/client/src/collection.ts:66

string

Filter<TSchema> = {}

ReadOptions = {}

Promise<unknown[]>


drop(options?): Promise<boolean>

Defined in: packages/client/src/collection.ts:208

Move the collection (table) to “Recently deleted” in the app.

WriteOptions = {}

Promise<boolean>


dropIndex(name, options?): Promise<boolean>

Defined in: packages/client/src/collection.ts:201

string

WriteOptions = {}

Promise<boolean>


estimatedDocumentCount(): Promise<number>

Defined in: packages/client/src/collection.ts:62

Count without checking Drive for app edits first (fast, may be a few seconds behind).

Promise<number>


find(filter?, options?): FindCursor<WithId<TSchema>>

Defined in: packages/client/src/collection.ts:42

Filter<TSchema> = {}

FindOptions = {}

FindCursor<WithId<TSchema>>


findOne(filter?, options?): Promise<WithId<TSchema> | null>

Defined in: packages/client/src/collection.ts:46

Filter<TSchema> = {}

Omit<FindOptions, "limit" | "skip" | "batchSize"> = {}

Promise<WithId<TSchema> | null>


findOneAndDelete(filter, options?): Promise<WithId<TSchema> | null>

Defined in: packages/client/src/collection.ts:150

Filter<TSchema>

WriteOptions & object = {}

Promise<WithId<TSchema> | null>


findOneAndUpdate(filter, update, options?): Promise<WithId<TSchema> | null>

Defined in: packages/client/src/collection.ts:134

Filter<TSchema>

UpdateFilter<TSchema>

FindOneAndUpdateOptions = {}

Promise<WithId<TSchema> | null>


insertMany(documents, options?): Promise<InsertManyResult>

Defined in: packages/client/src/collection.ts:95

Up to 1,000 documents per call, all or nothing.

OptionalId<TSchema>[]

WriteOptions = {}

Promise<InsertManyResult>


insertOne(document, options?): Promise<InsertOneResult>

Defined in: packages/client/src/collection.ts:90

OptionalId<TSchema>

WriteOptions = {}

Promise<InsertOneResult>


listIndexes(): ArrayCursor<IndexInfo>

Defined in: packages/client/src/collection.ts:195

ArrayCursor<IndexInfo>


replaceOne(filter, replacement, options?): Promise<UpdateResult>

Defined in: packages/client/src/collection.ts:118

Filter<TSchema>

OptionalId<TSchema>

Omit<UpdateOptions, "sort"> = {}

Promise<UpdateResult>


updateMany(filter, update, options?): Promise<UpdateResult>

Defined in: packages/client/src/collection.ts:110

Filter<TSchema>

UpdateFilter<TSchema>

Omit<UpdateOptions, "sort"> = {}

Promise<UpdateResult>


updateOne(filter, update, options?): Promise<UpdateResult>

Defined in: packages/client/src/collection.ts:102

Filter<TSchema>

UpdateFilter<TSchema>

UpdateOptions = {}

Promise<UpdateResult>


watch(): ChangeStream<WithId<TSchema>>

Defined in: packages/client/src/collection.ts:213

Follow inserts, updates and deletes in this collection.

ChangeStream<WithId<TSchema>>

Made by Faeiz Furqan