sculejs
sculejs copied to clipboard
add support for callbacks on I/O bound operations
At the moment there is no facility to provide callbacks on I/O bound operations such as loading data from disk - we need to add this functionality. An example might be:
sculedb.factoryCollection('scule+nodejs://collection', {secret:'test', path:'/tmp'}, function(err, data) {
// do something with err or data here
});
It'd also be good to normalize callbacks on existing non-blocking functions to use the same signature and passing error objects rather than throwing them:
collection.count({i:{$gte:5000}, n:{$lte:80}}, {}, function(err, data) {
if (err) {
// handle error
}
// handle data
});
Hi! Is that in progress?
Hey Anush, this is coming in the next stable release, probably in the next week or so :-)
Good news! Because it's required by the my project and I'm about to add it by myself.
Hi Dan, is this going to be fixed any time soon? I would like to use sculejs for storing data in nodejs application (using nodejs storage engine) and current approach of throwing exception upon error in asynchronous IO callback makes sculejs pretty much unusable in such environment since it's not possible to handle errors from reads/writes.
What I would need is that all user provided callbacks are called with (error, result) arguments and remove all exception throws from read/write storage engine operations. I guess this will required change of major revision number for sculejs npm package as it is backward incompatible change.
There should now be callbacks available on all IO bound operations, however they don't follow the convention of f(err, result). Since this will likely be a breaking change for most users I'll introduce that convention in v0.2.0 along with a promise based interface to the Database and Collection classes.