3 ms·
db.Put('myKey', {some: 'data'}, (value, err) => {}) It annoys me that it reverses the standard (err, value) callback convention that everyone else uses. An ad
by tlb 7y ago
db.Put('myKey', {some: 'data'}, (value, err) => {})
It annoys me that it reverses the standard (err, value) callback convention that everyone else uses.
An advantage of the standard is that you might have 0, or 2 or more value arguments to the callback. So you can return (err) or (err, value) or (err, value, optionalExtraValue) and it's fairly consistent.
- justjake 7y agoWow, that's totally my bad (Write a lot of Go at my day job). Can definitely fix that one. Will bump to 2.0.0 when I get home.
- laurent123456 7y agoMethod names that start with uppercase is also something you'll see more in Go or C# but not so much in JavaScript. `db.put()` would be the JS way.
- breck 7y agoI agree with your point. Just want to mention if you are using callbacks, might be worth looking at switching to async/await.
- justjake 7y agoIt supports both! If you don't provide a callback it'll return a promise.