atomicrecord
Version:
Super lightweight node.js ActiveRecord ORM layer for FoundationDB
31 lines (24 loc) • 691 B
text/coffeescript
AtomicList = require('./atomiclist')
fdb = require('fdboost')()
db = fdb.open()
module.exports = class AtomicQueue extends AtomicList
constructor: (recordsOrSize, options) ->
super(recordsOrSize)
if (!options)
if (typeof(recordsOrSize) is 'object' && !(recordsOrSize instanceof Array))
options = recordsOrSize
else
options = {}
if (options.batchSaveDelay)
transaction = (tr, callback) =>
(tr, callback)
complete = (err) ->
setInterval =>
db.doTransaction(transaction, complete) if > 0
, options.batchSaveDelay
save: (tr, callback) ->
cb = (err) =>
= 0 if !err
callback(err)
super(tr, cb)
return