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.
Type Parameters
Section titled “Type Parameters”TSchema
Section titled “TSchema”TSchema extends object = Document
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Collection<
TSchema>(http,collectionName,onStream?):Collection<TSchema>
Defined in: packages/client/src/collection.ts:33
Parameters
Section titled “Parameters”HttpClient
collectionName
Section titled “collectionName”string
The collection’s API name.
onStream?
Section titled “onStream?”(stream) => void
Returns
Section titled “Returns”Collection<TSchema>
Properties
Section titled “Properties”collectionName
Section titled “collectionName”
readonlycollectionName:string
Defined in: packages/client/src/collection.ts:36
The collection’s API name.
Methods
Section titled “Methods”aggregate()
Section titled “aggregate()”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.
Type Parameters
Section titled “Type Parameters”T = Document
Parameters
Section titled “Parameters”pipeline
Section titled “pipeline”Document[]
options?
Section titled “options?”ReadOptions = {}
Returns
Section titled “Returns”ArrayCursor<T>
bulkWrite()
Section titled “bulkWrite()”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.
Parameters
Section titled “Parameters”operations
Section titled “operations”AnyBulkWriteOperation<TSchema>[]
options?
Section titled “options?”WriteOptions = {}
Returns
Section titled “Returns”Promise<BulkWriteResult>
countDocuments()
Section titled “countDocuments()”countDocuments(
filter?,options?):Promise<number>
Defined in: packages/client/src/collection.ts:57
Parameters
Section titled “Parameters”filter?
Section titled “filter?”Filter<TSchema> = {}
options?
Section titled “options?”ReadOptions = {}
Returns
Section titled “Returns”Promise<number>
createIndex()
Section titled “createIndex()”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.
Parameters
Section titled “Parameters”Record<string, 1 | -1>
options?
Section titled “options?”WriteOptions & object = {}
Returns
Section titled “Returns”Promise<string>
deleteMany()
Section titled “deleteMany()”deleteMany(
filter,options?):Promise<DeleteResult>
Defined in: packages/client/src/collection.ts:130
Parameters
Section titled “Parameters”filter
Section titled “filter”Filter<TSchema>
options?
Section titled “options?”WriteOptions = {}
Returns
Section titled “Returns”Promise<DeleteResult>
deleteOne()
Section titled “deleteOne()”deleteOne(
filter,options?):Promise<DeleteResult>
Defined in: packages/client/src/collection.ts:126
Parameters
Section titled “Parameters”filter
Section titled “filter”Filter<TSchema>
options?
Section titled “options?”WriteOptions = {}
Returns
Section titled “Returns”Promise<DeleteResult>
distinct()
Section titled “distinct()”distinct(
key,filter?,options?):Promise<unknown[]>
Defined in: packages/client/src/collection.ts:66
Parameters
Section titled “Parameters”string
filter?
Section titled “filter?”Filter<TSchema> = {}
options?
Section titled “options?”ReadOptions = {}
Returns
Section titled “Returns”Promise<unknown[]>
drop()
Section titled “drop()”drop(
options?):Promise<boolean>
Defined in: packages/client/src/collection.ts:208
Move the collection (table) to “Recently deleted” in the app.
Parameters
Section titled “Parameters”options?
Section titled “options?”WriteOptions = {}
Returns
Section titled “Returns”Promise<boolean>
dropIndex()
Section titled “dropIndex()”dropIndex(
name,options?):Promise<boolean>
Defined in: packages/client/src/collection.ts:201
Parameters
Section titled “Parameters”string
options?
Section titled “options?”WriteOptions = {}
Returns
Section titled “Returns”Promise<boolean>
estimatedDocumentCount()
Section titled “estimatedDocumentCount()”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).
Returns
Section titled “Returns”Promise<number>
find()
Section titled “find()”find(
filter?,options?):FindCursor<WithId<TSchema>>
Defined in: packages/client/src/collection.ts:42
Parameters
Section titled “Parameters”filter?
Section titled “filter?”Filter<TSchema> = {}
options?
Section titled “options?”FindOptions = {}
Returns
Section titled “Returns”FindCursor<WithId<TSchema>>
findOne()
Section titled “findOne()”findOne(
filter?,options?):Promise<WithId<TSchema> |null>
Defined in: packages/client/src/collection.ts:46
Parameters
Section titled “Parameters”filter?
Section titled “filter?”Filter<TSchema> = {}
options?
Section titled “options?”Omit<FindOptions, "limit" | "skip" | "batchSize"> = {}
Returns
Section titled “Returns”Promise<WithId<TSchema> | null>
findOneAndDelete()
Section titled “findOneAndDelete()”findOneAndDelete(
filter,options?):Promise<WithId<TSchema> |null>
Defined in: packages/client/src/collection.ts:150
Parameters
Section titled “Parameters”filter
Section titled “filter”Filter<TSchema>
options?
Section titled “options?”WriteOptions & object = {}
Returns
Section titled “Returns”Promise<WithId<TSchema> | null>
findOneAndUpdate()
Section titled “findOneAndUpdate()”findOneAndUpdate(
filter,update,options?):Promise<WithId<TSchema> |null>
Defined in: packages/client/src/collection.ts:134
Parameters
Section titled “Parameters”filter
Section titled “filter”Filter<TSchema>
update
Section titled “update”UpdateFilter<TSchema>
options?
Section titled “options?”Returns
Section titled “Returns”Promise<WithId<TSchema> | null>
insertMany()
Section titled “insertMany()”insertMany(
documents,options?):Promise<InsertManyResult>
Defined in: packages/client/src/collection.ts:95
Up to 1,000 documents per call, all or nothing.
Parameters
Section titled “Parameters”documents
Section titled “documents”OptionalId<TSchema>[]
options?
Section titled “options?”WriteOptions = {}
Returns
Section titled “Returns”Promise<InsertManyResult>
insertOne()
Section titled “insertOne()”insertOne(
document,options?):Promise<InsertOneResult>
Defined in: packages/client/src/collection.ts:90
Parameters
Section titled “Parameters”document
Section titled “document”OptionalId<TSchema>
options?
Section titled “options?”WriteOptions = {}
Returns
Section titled “Returns”Promise<InsertOneResult>
listIndexes()
Section titled “listIndexes()”listIndexes():
ArrayCursor<IndexInfo>
Defined in: packages/client/src/collection.ts:195
Returns
Section titled “Returns”replaceOne()
Section titled “replaceOne()”replaceOne(
filter,replacement,options?):Promise<UpdateResult>
Defined in: packages/client/src/collection.ts:118
Parameters
Section titled “Parameters”filter
Section titled “filter”Filter<TSchema>
replacement
Section titled “replacement”OptionalId<TSchema>
options?
Section titled “options?”Omit<UpdateOptions, "sort"> = {}
Returns
Section titled “Returns”Promise<UpdateResult>
updateMany()
Section titled “updateMany()”updateMany(
filter,update,options?):Promise<UpdateResult>
Defined in: packages/client/src/collection.ts:110
Parameters
Section titled “Parameters”filter
Section titled “filter”Filter<TSchema>
update
Section titled “update”UpdateFilter<TSchema>
options?
Section titled “options?”Omit<UpdateOptions, "sort"> = {}
Returns
Section titled “Returns”Promise<UpdateResult>
updateOne()
Section titled “updateOne()”updateOne(
filter,update,options?):Promise<UpdateResult>
Defined in: packages/client/src/collection.ts:102
Parameters
Section titled “Parameters”filter
Section titled “filter”Filter<TSchema>
update
Section titled “update”UpdateFilter<TSchema>
options?
Section titled “options?”UpdateOptions = {}
Returns
Section titled “Returns”Promise<UpdateResult>
watch()
Section titled “watch()”watch():
ChangeStream<WithId<TSchema>>
Defined in: packages/client/src/collection.ts:213
Follow inserts, updates and deletes in this collection.
Returns
Section titled “Returns”ChangeStream<WithId<TSchema>>
Made by Faeiz Furqan