JSPM

block-sequence-mysql

0.1.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q44591F
  • License ISC

A mysql implementation of block-sequence

Package Exports

  • block-sequence-mysql

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (block-sequence-mysql) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

block-sequence-mysql

A MySQL implementation of block-sequence.

Usage

var BlockArray = require('block-sequence').BlockArray
var init = require('block-sequence-mysql')

// Initialise the MySql Block Sequence Driver
init({ host: '127.0.0.1', database: 'bs_test', user: 'root' }, function(err, driver) {
    if (err) throw err

    // Ensure the sequence exists
    driver.ensure({ name: 'my-sequence' }, function(err, sequence) {
        if (err) throw err

        // Create a block array containing 1000 ids per block (defaults to 2 blocks)
        var idGenerator = new BlockArray({ block: { driver: driver, size: 1000 } })

        // Grab the next id
        idGenerator.next(function(err, id) {
            if (err) throw err
            console.log(id)
        })
    })
})

See https://www.npmjs.com/package/mysql for all connection parameters