interface IMongoCollection
Since 0.1.0

A structural subset of the driver Collection — the methods the data source calls to serve the six IDataSource methods.

The adapter reads the driver's documented return shapes (see the milestone's §1.1: insertOne{ acknowledged, insertedId }, findOneAndUpdate → the document directly, deleteOne{ deletedCount }) rather than the driver's own classes, so a faithful test double that reproduces those shapes is assignable here — the recurring contract-violating double this seam exists to prevent.

Methods

insertOne(
document: Record<string, unknown>,
): Promise<
{ acknowledged: boolean; insertedId: IMongoObjectId | string | number; }
>

Inserts one document.

findOne(
filter: Record<string, unknown>,
options?:
MongoOptions
& { projection?: Record<string, 0 | 1>; sort?: Record<string, unknown>; }
): Promise<Record<string, unknown> | null>

Finds a single document.

find(
filter: Record<string, unknown>,
options?:
MongoOptions
& { sort?: Record<string, unknown>; skip?: number; limit?: number; projection?: Record<string, 0 | 1>; }
): IMongoCursor

Finds matching documents.

findOneAndUpdate(
filter: Record<string, unknown>,
update: Record<string, unknown>,
): Promise<Record<string, unknown> | null>

Finds one document and applies an update, returning the updated document.

deleteOne(
filter: Record<string, unknown>,
): Promise<{ deletedCount: number; }>

Deletes matching documents.

countDocuments(
filter: Record<string, unknown>,
): Promise<number>

Counts matching documents.

Usage

import { type IMongoCollection } from "database-plugin/src/index.ts";