Skip to content
This repository has been archived by the owner on Feb 10, 2022. It is now read-only.

[v3] save won't return the saved document #156

Open
zaaack opened this issue Jan 11, 2017 · 5 comments
Open

[v3] save won't return the saved document #156

zaaack opened this issue Jan 11, 2017 · 5 comments

Comments

@zaaack
Copy link
Contributor

zaaack commented Jan 11, 2017

Looks like create/update have the same problem. Since bluebird is not used anymore, I highly recommend sindresorhus's p-tap package.

@zaaack
Copy link
Contributor Author

zaaack commented Jan 11, 2017

Sorry, after looking into the source deeper, I find out the code could change to something like

const doc = new Doc({ ...attrs })
doc.save()
return doc

but returning the model instance still could be very helpful.

@vadimdemedes
Copy link
Owner

but returning the model instance still could be very helpful.

Could you explain where it could be useful?

@zaaack
Copy link
Contributor Author

zaaack commented Mar 17, 2017

Actually, the main reason is this breaking my code when upgrading from v2. In v2, I have some code like this, and not working anymore. This might be not a big deal, some document could help.

const post = (new Post({ title: 'Some title' })).save()

https://github.com/vadimdemedes/mongorito/blob/master/lib/mongorito.js#L609

@zaaack zaaack closed this as completed Mar 17, 2017
@vadimdemedes
Copy link
Owner

This is a good point, I think I'd like that too.

@vadimdemedes vadimdemedes reopened this Mar 18, 2017
@VitaliyLavrenko
Copy link

Save method is async process so it return Promise, why it should return something else?

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

No branches or pull requests

3 participants