felixge/node-dirty

getting back row

angelochen960 opened this issue · 3 comments

Hi,
I run the sample, so I got a user.db with json entries, I tried to retrieve them back with following code, why not thing was shown?

var dirty = require('dirty');
var db = dirty('user.db');

db.forEach(function(key, val) {
console.log('Found key: %s, val: %j', key, val);
});

db.on('drain', function() {
console.log('All records are saved on disk now.');
});

Most likely the file hasn't loaded yet, bout hard to know for sure without seeing the user.db file. Try the following:

db.on('load', function() {
  db.forEach(function(key, val) {
    console.log('Found key: %s, val: %j', key, val);
  });
});

that reads back rows. when you set a new value for an existing key, the old entry still exists in user.db, when we do a get, is it always the latest version of the same record returned? is there an option to remove those old versions? thanks,

It's an append only file. Last row for a given key is active.

On Apr 20, 2013, at 1:10 AM, angelochen960 notifications@github.com wrote:

that reads back rows. when you set a new value for an existing key, the old entry still exists in user.db, when we do a get, is it always the latest version of the same record returned? is there an option to remove those old versions? thanks,


Reply to this email directly or view it on GitHub.