Nebulous Puffy Marshmallows

    @sealsystems/counter-storage

    0.0.8 • Public • Published

    @sealsystems/counter-storage

    CircleCI AppVeyor

    @sealsystems/counter-storage manages handling of counters persisted in a MongoDB.

    Installation

    $ npm install @sealsystems/counter-storage

    Quick start

    First you need to add a reference to @sealsystems/counter-storage within your application:

    const counterStorage = require('@sealsystems/counter-storage');

    Then you can connect to a MongoDB. For that call the connect function and provide the database's connection string using the url property:

    const storage = await counterStorage.connect({
      url: 'mongodb://localhost:27017'
    });

    Optionally, you may also specify the number of connection retries:

    const storage = await counterStorage.connect({
      url: 'mongodb://localhost:27017',
      connectionRetries: 10
    });

    Get next counter value

    To get the next counter value call the getCounter function and provide its name. Optionally you can provide the increment as second argument, default increment is 1:

    const newCounterValue = await storage.getCounter('hugo');

    With increment:

    const newCounterValue = await storage.getCounter('hugo', 100);

    Running the build

    To build this module use roboter.

    $ bot

    Keywords

    none

    Install

    npm i @sealsystems/counter-storage

    DownloadsWeekly Downloads

    1

    Version

    0.0.8

    License

    MIT

    Unpacked Size

    18.6 kB

    Total Files

    15

    Last publish

    Collaborators

    • gel
    • comgit
    • seal-mt
    • michaelscherer-seal