/** *
* * ## Installation * * ```bash npm2yarn * npm install @auth/mongodb-adapter mongodb * ``` * * @module @auth/mongodb-adapter */ import { ObjectId } from "mongodb" import type { Adapter, AdapterUser, AdapterAccount, AdapterSession, VerificationToken, } from "@auth/core/adapters" import type { MongoClient } from "mongodb" /** * This adapter uses https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-2.html#using-declarations-and-explicit-resource-management. * This feature is very new and requires runtime polyfills for `Symbol.asyncDispose` in order to work properly in all environments. * It is also required to set in the `tsconfig.json` file the compilation target to `es2022` or below and configure the `lib` option to include `esnext` or `esnext.disposable`. * * You can find more information about this feature and the polyfills in the link above. */ // @ts-expect-error read only property is not assignable Symbol.asyncDispose ??= Symbol("Symbol.asyncDispose") /** This is the interface of the MongoDB adapter options. */ export interface MongoDBAdapterOptions { /** * The name of the {@link https://www.mongodb.com/docs/manual/core/databases-and-collections/#collections MongoDB collections}. */ collections?: { Users?: string Accounts?: string Sessions?: string VerificationTokens?: string } /** * The name you want to give to the MongoDB database */ databaseName?: string /** * Callback function for managing the closing of the MongoDB client. * This could be useful when `client` is provided as a function returning MongoClient. * It allows for more customized management of database connections, * addressing persistence, container reuse, and connection closure issues. */ onClose?: (client: MongoClient) => Promise