method IMongoCollection.findOne
IMongoCollection.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.

Parameters

filter: Record<string, unknown>

The match filter

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

The findOne options (projection/sort)

Return Type

Promise<Record<string, unknown> | null>

The matching document, or null

Usage

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