Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Promise support #25

Closed
soullivaneuh opened this issue Oct 13, 2022 · 2 comments
Closed

Promise support #25

soullivaneuh opened this issue Oct 13, 2022 · 2 comments

Comments

@soullivaneuh
Copy link

Is your feature request related to a problem? Please describe.
For complex requests implementation, like for data migration, I need to fetch data from many databases and use them to update others.

Using the current callback system is quite limiting, forcing me to chain the data fetch callbacks until the update one.

Describe the solution you'd like

Instead of callback, make this library embracing promises.

Using promises also allow us to use the async/await keywords to have a more imperative code structure that can be easier to read and understand on some cases. For example:

const user = await models.users.findOne(...);
await model.orders.update({ _id: 42 }, { customerId: user._id });

Describe alternatives you've considered
I don't see any alternative.

Additional context

This was a subject already evoked on the original project (louischatriot#673) but without any official answer.

@arantes555
Copy link

@soullivaneuh I think you may have missed it, but this version of NeDB has supported a Promise-based interface for months. See https://github.com/seald/nedb/blob/master/CHANGELOG.md#300---2022-03-16

@soullivaneuh
Copy link
Author

Oh my god, I indeed come from directly the old NeDB project with my old implementation.

Sorry for this stupid move, and thanks for the quick answer!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants