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

x/hex/src/data/deps.ts>mongo.Collection

An ecosystem delivering practices, philosophy and portability.
Go to Latest
class mongo.Collection
import { mongo } from "https://deno.land/x/hex@0.5.15/src/data/deps.ts";
const { Collection } = mongo;

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>
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>
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; }>
replaceOne(
filter: Filter<T>,
replacement: InsertDocument<T>,
options?: UpdateOptions,
)
updateMany(
filter: Filter<T>,
options?: UpdateOptions,
)
updateOne(
filter: Filter<T>,
update: UpdateFilter<T>,
options?: UpdateOptions,
)