Jeriho
Jeriho

Reputation: 7299

One to many relation: retrieving documents with a single query

Returning to classic mongodb example (posts and users):

Posts:

{title: "Greetings", body:"Hello world", userId:12345}

Users:

{_id:12345, name:"John Smith", email:[email protected]"}

How to get post

{title: "Greetings", body:"Hello world", <username>:"John Smith"}

with a sigle query?

Upvotes: 4

Views: 1970

Answers (1)

user2665694
user2665694

Reputation:

MongoDB is not an RDBMS - so NO JOINS - either you use two queries or you use embedding or you look at "database references".

Upvotes: 3

Related Questions