-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
db.getSortedSetRange is not a function #183
Comments
i think I know why, i will fix it tomorrow |
hey, I found the issue, but it's NOT** (edit) an easy fix, the thing is that you're trying to use the database before it had some time to load - there is a callback to timeout wayvar async = require('async');
var Data = require('../nodebb-plugin-import/server/data.js');
// just wrap it in a timeout till it's ready.
setTimeout(function() {
Data.eachPost(console.log,
function (err) {
if (err) {
throw err;
}
console.log("DONE!!");
}
);
}, 3000); // 3 seconds worked for me, you might need more depending on how large your db-index is. interval wayvar async = require('async');
var Data = require('../nodebb-plugin-import/server/data.js');
var go = function () {
Data.eachPost(console.log,
function (err) {
if (err) {
throw err;
}
console.log("DONE!!");
}
);
};
// you can test it every 500ms
var interval = setInterval(function() {
if (Data.db.client) {
clearInterval(interval);
go();
}
}, 500); Both solutions are very stupid, but if you're writing a one-off script, they should work |
Thank you so much @akhoury. This worked! |
Ops... let me leave it open... |
Sorry to bother you again, this is probably something small, and likely my fault.
Here's the simple file I created:
When I run it I get this error:
Any ideas why it's not defined? Looking at the db object it seems to have the proper configs (mongodb, localhost, etc)...
The text was updated successfully, but these errors were encountered: