Here's a full script for export, put in same folder as config.json
:
var fs = require('fs');
var nconf = require('nconf');
nconf.argv().env().file({
file: './config.json'
});
var db = require('./src/database');
function do_export(set, prefix) {
db.getSortedSetRange(set, 0, -1, function(err, ids) {
var keys = ids.map(function(id){ return prefix + id; });
db.getObjects(keys, function(err, data) {
fs.writeFile('db.export.' + set + '.json', JSON.stringify(data), function() {
console.log('Wrote '+set);
});
});
});
}
db.init(function() {
do_export('posts:pid', 'post:');
do_export('topics:tid', 'topic:');
});