connect-mongo

  • Version 5.1.0
  • Published
  • 730 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<Collection<InternalSessionType>>;

        method all

        all: (
        callback: (
        err: any,
        obj?: session.SessionData[] | { [sid: string]: session.SessionData }
        ) => 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: session.SessionData,
          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;

            Namespaces

            namespace kruptein

            module 'kruptein' {}
            • If you import a dependency which does not include its own type definitions, TypeScript will try to find a definition for it by following the typeRoots compiler option in tsconfig.json. For this project, we've configured it to fall back to this folder if nothing is found in node_modules/@types.

              Often, you can install the DefinitelyTyped (https://github.com/DefinitelyTyped/DefinitelyTyped) type definition for the dependency in question. However, if no one has yet contributed definitions for the package, you may want to declare your own. (If you're using the noImplicitAny compiler options, you'll be required to declare it.)

              This is an example type definition which allows import from module-name, e.g.:

              import something from 'module-name';
              something();

            class Kruptein

            class Kruptein {}

              method get

              get: (secret: string, ciphertext: string, callback: Callback) => void;

                method set

                set: (secret: string, plaintext: string | any, callback: Callback) => void;

                  Package Files (3)

                  Dependencies (2)

                  Dev Dependencies (40)

                  Peer Dependencies (2)

                  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>