Setu-TS
    Preparing search index...

    Interface IMongoCollection

    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.

    0.2.0

    interface IMongoCollection {
        countDocuments(
            filter: Record<string, unknown>,
            options?: MongoOptions,
        ): Promise<number>;
        deleteOne(
            filter: Record<string, unknown>,
            options?: MongoOptions,
        ): Promise<{ deletedCount: number }>;
        find(
            filter: Record<string, unknown>,
            options?: MongoOptions & {
                limit?: number;
                projection?: Record<string, 0 | 1>;
                skip?: number;
                sort?: unknown;
            },
        ): IMongoCursor;
        findOne(
            filter: Record<string, unknown>,
            options?: MongoOptions & {
                projection?: Record<string, 0 | 1>;
                sort?: unknown;
            },
        ): Promise<Record<string, unknown> | null>;
        findOneAndUpdate(
            filter: Record<string, unknown>,
            update: Record<string, unknown>,
            options: IMongoCollectionFindOneAndUpdateOptions,
        ): Promise<Record<string, unknown> | null>;
        insertOne(
            document: Record<string, unknown>,
            options?: MongoOptions,
        ): Promise<
            { acknowledged: boolean; insertedId: string
            | number
            | IMongoObjectId },
        >;
    }
    Index
    • Finds matching documents.

      Parameters

      • filter: Record<string, unknown>

        The match filter

      • Optionaloptions: MongoOptions & {
            limit?: number;
            projection?: Record<string, 0 | 1>;
            skip?: number;
            sort?: unknown;
        }

        The find options (sort/skip/limit/projection)

        • Optionallimit?: number
        • Optionalprojection?: Record<string, 0 | 1>
        • Optionalskip?: number
        • Optionalsort?: unknown

          Deliberately unknown — see IMongoCollection.findOne: the real Sort union admits strings and arrays, which a Record typing rejected.

      Returns IMongoCursor

      A cursor that materializes the matching documents with toArray()

    • Finds a single document.

      Parameters

      • filter: Record<string, unknown>

        The match filter

      • Optionaloptions: MongoOptions & { projection?: Record<string, 0 | 1>; sort?: unknown }

        The findOne options (projection/sort)

        • Optionalprojection?: Record<string, 0 | 1>
        • Optionalsort?: unknown

          Deliberately unknown: the real driver's FindOptions.sort is the Sort union, which admits bare strings and arrays, so a Record<string, unknown> here made the real collection fail this member (X47-1). The adapter builds a Record and the real driver accepts it; unknown keeps both assignable.

      Returns Promise<Record<string, unknown> | null>

      The matching document, or null