Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/mongo/src/collection/mod.ts>Collection

MongoDB driver for Deno
Extremely Popular
Go to Latest
class Collection
import { Collection } from "https://deno.land/x/mongo@v0.31.1/src/collection/mod.ts";

Constructors

new
Collection(
protocol: WireProtocol,
dbName: string,
name: string,
)

Methods

aggregate<U = T>(pipeline: AggregatePipeline<U>[], options?: AggregateOptions): AggregateCursor<U>
deprecated
count(filter?: Filter<T>, options?: CountOptions): Promise<number>
countDocuments(filter?: Filter<T>, options?: CountOptions): Promise<number>
createIndexes(options: CreateIndexOptions)
deleteMany(filter: Filter<T>, options?: DeleteOptions): Promise<number>
deleteOne(filter: Filter<T>, options?: DeleteOptions)
distinct(
key: string,
query?: Filter<T>,
options?: DistinctOptions,
)
drop(options?: DropOptions): Promise<void>
dropIndexes(options: DropIndexOptions)
estimatedDocumentCount(): Promise<number>
find(filter?: Filter<T>, options?: FindOptions): FindCursor<T>
findAndModify(filter?: Filter<T>, options?: FindAndModifyOptions<T>): Promise<T | undefined>

Find and modify a document in one, returning the matching document.

findOne(filter?: Filter<T>, options?: FindOptions): Promise<T | undefined>
deprecated
insert(docs: InsertDocument<T> | InsertDocument<T>[], options?: InsertOptions)
insertMany(docs: InsertDocument<T>[], options?: InsertOptions): Promise<{ insertedIds: (ObjectId | Required<InsertDocument<T>>["_id"])[]; insertedCount: number; }>
insertOne(doc: InsertDocument<T>, options?: InsertOptions)
replaceOne(
filter: Filter<T>,
replacement: InsertDocument<T>,
options?: UpdateOptions,
)
updateMany(
filter: Filter<T>,
doc: UpdateFilter<T>,
options?: UpdateOptions,
)
updateOne(
filter: Filter<T>,
update: UpdateFilter<T>,
options?: UpdateOptions,
)