connect-mongo

  • Version 4.6.0
  • Published
  • 109 kB
  • 2 dependencies
  • MIT license

Install

npm i connect-mongo
yarn add connect-mongo
pnpm add connect-mongo

Overview

MongoDB session store for Express and Connect

Index

Classes

class MongoStore

class MongoStore extends session.Store {}

    constructor

    constructor({
    collectionName,
    ttl,
    mongoOptions,
    autoRemove,
    autoRemoveInterval,
    touchAfter,
    stringify,
    crypto,
    ...required
    }: ConnectMongoOptions);

      property collectionP

      collectionP: Promise<any>;

        method all

        all: (
        callback: (err: any, obj?: any[] | { [sid: string]: any }) => void
        ) => void;
        • Get all sessions in the store as an array

        method clear

        clear: (callback?: (err: any) => void) => void;
        • Delete all sessions from the store.

        method close

        close: () => Promise<void>;
        • Close database connection

        method create

        static create: (options: ConnectMongoOptions) => MongoStore;

          method destroy

          destroy: (sid: string, callback?: (err: any) => void) => void;
          • Destroy/delete a session from the store given a session ID (sid)

            Parameter sid

            session ID

          method get

          get: (sid: string, callback: (err: any, session?: any) => void) => void;
          • Get a session from the store given a session ID (sid)

            Parameter sid

            session ID

          method length

          length: (callback: (err: any, length: number) => void) => void;
          • Get the count of all sessions in the store

          method set

          set: (sid: string, session: any, callback?: (err: any) => void) => void;
          • Upsert a session into the store given a session ID (sid) and session (session) object.

            Parameter sid

            session ID

            Parameter session

            session object

          method touch

          touch: (
          sid: string,
          session: session.SessionData & { lastModified?: Date },
          callback?: (err: any) => void
          ) => void;

            Package Files (2)

            Dependencies (2)

            Dev Dependencies (40)

            Peer Dependencies (1)

            Badge

            To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

            You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/connect-mongo.

            • Markdown
              [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/connect-mongo)
            • HTML
              <a href="https://www.jsdocs.io/package/connect-mongo"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>