node-sync
node-sync copied to clipboard
Not work with promise-style library
I'm mainly using Mongoose for my project and I hope I can achieve something like this:
var person = Person.findOne.sync({name: "John"}); // not work
var count = Person.count.sync(); // works
Sadly, 'findOne' function uses promise (https://github.com/LearnBoost/mongoose/blob/3.8.x/lib/query.js#L991) and it breaks the node-sync, while 'count' doesn't use. Is there a way to support promise?
Hi,
try this
var person = Person.findOne.sync(Person, {name: "John"}); // not work
@hoan006 I added ".syncp" and ".futurep" functions, they work with promises: https://github.com/airs0urce/node-sync/commit/c62f1a9023094adf6bc4f4134f9faa60e68bc94f
Not a brilliant because of copy/paste, but it works with functions that return Promise. I made this to be able to move to generators (co) or async/await in future.