Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
function create(record, callback) {
var table = record._table
try {
var fields = prepareFields(record, table, { _version: 1 })
} catch (err) {
return callback(err)
}
checkKeys(table, record, function(err) {
if (err) return callback(err)
redis.incr(table + ':id', function(err, id) {
if (err) return callback(err)
saveFields(fields, table, id, function(err) {
if (err) return callback(err)
redis.rpush(table, id, function(err) {
if (err) return callback(err)
self.retrieve({ _table:table, _id:id }, function(err, record) {
if (err) return callback(err)
callback(null, record)
})
})
})
})
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment