Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • I think you gave the best answer. I was going to jump in but; you created a lot of value here. Good answer. Commented Jan 15, 2018 at 7:27
  • Thank you, an alternative to .find() is .findOne() - .find() returns and array, while .findOne() returns the first record it finds(object), ignoring the rest. This is good in cases where you are looking up documents with a unique field - like by email, or ID.
    – David Alsh
    Commented Jan 16, 2018 at 1:01
  • 1
    @darshanan do you mean how do you search through values in nested keys on a document? If so it's db.collections.find({"keyOne.keyTwo":"search"})
    – David Alsh
    Commented May 24, 2018 at 23:56
  • @DavidAlsh Please look into above comment. Commented May 25, 2018 at 6:49