can shell commands use in mongoose directly? #4894

RifeWang opened this Issue Jan 12, 2017 · 2 comments


None yet

2 participants


If i have some data defined in mongoDB , i can get documents in shell through db.mycollection.find(), my question is can i write the same command db.mycollection.find() as a param through a function and then get the result , and do i have to use schema or model?

varunjayaraman commented Jan 12, 2017 edited

Sorry, I'm a bit confused about what you're asking. I think you're asking can you pass in mongo shell parameters to mongoose queries. If so, the answer is yes. Here's an example:

mongodb shell command

db.users.update({ _id: someRandomId }, { $addToSet: { '': 'Audi' })

mongoose function

User.update({ _id: someRandomId }, { $addToSet: { '': ' } })

You have to use a model (not a schema, models are created from schemas).


@varunjayaraman I mean that i like mongojs's API that emulates the official mongodb API as much as possible , model and schema doesn't exit in official mongodb API , but i have to operate mongodb through model in mongoose, but i think i have a little understand about that way.

@RifeWang RifeWang closed this Jan 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment