react-native-db-models icon indicating copy to clipboard operation
react-native-db-models copied to clipboard

make api node style

Open plrthink opened this issue 9 years ago • 2 comments

By making callback node style, the first argument of callback is error, users can use something like bluebird.promisify to convert the callback style to the promise style.

plrthink avatar Oct 09 '15 07:10 plrthink

This is a good change but it might be a breaking change for many. I am kind of involved with some other stuff these days will merge it soon. untill then you can fix/ make sure it doesn't break the current applications

darkrishabh avatar Oct 16 '15 22:10 darkrishabh

It's been two years and this hasn't been merged. For anyone coming to this who only knows how to promisify using Bluebird or another third-party promisify function, here's how you do it with the add function as an example:

function myAdd(item) {
    return new Promise(resolve => db.add(item, result => resolve(result)))
}

myAdd will now return a promise that resolves to what db inserted.

kylegoetz avatar Oct 30 '17 03:10 kylegoetz