1.0.0 • Published 6 years ago

indexeddb-aol v1.0.0

Weekly downloads
4
License
SEE LICENSE IN LI...
Repository
github
Last release
6 years ago

Usage

var IndexedDBAOL = require('indexeddb-aol')
var assert = require('assert')

var aol = new IndexedDBAOT({name: 'test-log'})

// Append an entry.
db.append({x: 1}, function (error, index) {
  assert.ifError(error)
  assert.equal(index, 0)

  // Append another entry.
  db.append({y: 2}, function (error, index) {
    assert.ifError(error)
    assert.equal(index, 1)

    // Count entries on the log.
    db.count(function (error, count) {
      assert.ifError(error)
      assert.equal(count, 2)

      // Iterate entries...
      var iterated = []
      db.iterate(
        1, // ...starting from index 1.
        function iterate (index, entry, done) {
          iterated.push(entry)
          done()
        },
        function (error) {
          assert.ifError(error)
          assert.deepEqual(iterated, [{y: 2}])

          // Destroy the database.
          db.destroy(function () {
            // ...
          })
        }
      )
    })
  })
})

Licensing

This package is to free to use in open source under the terms of the License Zero Reciprocal Public License.

Licenses for use in closed and proprietary software are available via licensezero.com.

L0