Hierarchy

  • MongoDbWrapper

Implements

Constructors

Properties

client: undefined | MongoClient
db: undefined | Db

Methods

  • Connects to a MongoDB server.

    Parameters

    • url: string

      The connection string for the MongoDB server.

    • Optional options: MongoClientOptions

      Optional settings for the MongoDB driver.

    Returns Promise<void>

  • Returns the count of documents in a MongoDB collection that match the specified query.

    Returns

    A promise that resolves to the number of documents matching the query.

    Type Parameters

    • T extends {
          _id: any;
      }

    Parameters

    • collectionName: string

      The name of the collection to count.

    • query: Partial<T>

      The query to search for.

    Returns Promise<number>

  • Deletes multiple documents from a MongoDB collection that match the specified query.

    Returns

    A promise that resolves to the number of documents deleted.

    Type Parameters

    • T extends {
          _id: any;
      }

    Parameters

    • collectionName: string

      The name of the collection to delete from.

    • query: Partial<T>

      The query to search for.

    Returns Promise<number>

  • Deletes a single document from a MongoDB collection that matches the specified query.

    Returns

    A promise that resolves to the number of documents deleted.

    Type Parameters

    • T extends {
          _id: any;
      }

    Parameters

    • collectionName: string

      The name of the collection to delete from.

    • query: Partial<T>

      The query to search for.

    Returns Promise<number>

  • Returns an array of documents from a MongoDB collection that match the specified query.

    Returns

    A promise that resolves to an array of matching documents.

    Type Parameters

    • T extends {
          _id: any;
      }

    Parameters

    • collectionName: string

      The name of the collection to search.

    • query: Partial<T>

      The query to search for.

    Returns Promise<T[]>

  • Finds a single document in a MongoDB collection that matches the specified query.

    Returns

    A promise that resolves to the matching document, or null if no document is found.

    Type Parameters

    • T extends {
          _id: any;
      }

    Parameters

    • collectionName: string

      The name of the collection to search.

    • query: Partial<T>

      The query to search for.

    Returns Promise<null | T>

  • Finds a single document from a MongoDB collection that matches the specified query and deletes it.

    Returns

    A promise that resolves to the deleted document or null if no document was found.

    Type Parameters

    • T extends {
          _id: any;
      }

    Parameters

    • collectionName: string

      The name of the collection to delete from.

    • query: Partial<T>

      The query to search for.

    Returns Promise<null | T>

  • Finds a single document from a MongoDB collection that matches the specified query and updates it.

    Returns

    A promise that resolves to the updated document or null if no document was found.

    Type Parameters

    • T extends {
          _id: any;
      }

    Parameters

    • collectionName: string

      The name of the collection to update.

    • query: Partial<T>

      The query to search for.

    • update: Partial<any>

      The update operation to apply.

    • Optional options: {
          returnOriginal?: boolean;
      }

      Optional settings for the update operation.

      • Optional returnOriginal?: boolean

    Returns Promise<null | T>

  • Inserts multiple documents into a MongoDB collection.

    Returns

    A promise that resolves to the InsertManyResult.

    Type Parameters

    • T extends {
          _id?: any;
      }

    Parameters

    • collectionName: string

      The name of the collection to insert the documents into.

    • documents: OptionalId<T>[]

      An array of documents to insert.

    Returns Promise<InsertManyResult<T>>

  • Inserts a single document into a MongoDB collection.

    Returns

    A promise that resolves to the InsertOneResult.

    Type Parameters

    • T extends {
          _id: any;
      }

    Parameters

    • collectionName: string

      The name of the collection to insert the document into.

    • document: OptionalUnlessRequiredId<T>

      The document to insert.

    Returns Promise<InsertOneResult<T>>

  • Updates multiple documents in a MongoDB collection that match the specified query.

    Returns

    A promise that resolves to the number of documents updated.

    Type Parameters

    • T extends {
          _id: any;
      }

    Parameters

    • collectionName: string

      The name of the collection to update.

    • query: Partial<T>

      The query to search for.

    • update: Partial<any>

      The update operation to apply.

    Returns Promise<number>

  • Updates a single document in a MongoDB collection that matches the specified query.

    Returns

    A promise that resolves to the number of documents updated.

    Type Parameters

    • T extends {
          _id: any;
      }

    Parameters

    • collectionName: string

      The name of the collection to update.

    • query: Partial<T>

      The query to search for.

    • update: Partial<T>

      The update to apply.

    Returns Promise<number>

Generated using TypeDoc