Conversation
|
This is a good change but it might be a breaking change for many. |
|
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: myAdd will now return a promise that resolves to what db inserted. |
| collection.add(data_to_add, function(added_data_id){ | ||
| if(callback){ | ||
| callback(added_data_id) | ||
| callback(null, added_data_id) |
There was a problem hiding this comment.
Warning (95% confidence)
Inconsistency: The 'add_all' method calls 'callback(added_data)' without the error-first argument 'null', unlike all other methods in the file. This breaks the Node.js convention established in this PR.
Posted by PR Code Reviewer — AI-powered code review
| @@ -125,7 +125,7 @@ RNDBModel.create_db = function(db){ | |||
| ReactNativeStore.table(me.db_name).then(function(collection){ | |||
There was a problem hiding this comment.
Warning (85% confidence)
The 'erase_db' method calls 'collection.remove' which is likely intended to be 'collection.databaseData[me.db_name] = []' or a specific clear method. Calling 'remove' without a query might remove all items or behave unexpectedly depending on the underlying store implementation, and errors are not propagated to the callback.
Posted by PR Code Reviewer — AI-powered code review
By making callback node style, the first argument of callback is
error, users can use something likebluebird.promisifyto convert the callback style to the promise style.