开发者

One to many relation: retrieving documents with a single query

开发者 https://www.devze.com 2023-02-08 06:16 出处:网络
Returning to classic mongodb example (posts and users)开发者_如何学运维: Posts: {title: \"Greetings\", body:\"Hello world\", userId:12345}

Returning to classic mongodb example (posts and users)开发者_如何学运维:

Posts:

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

Users:

{_id:12345, name:"John Smith", email:john@smith.org"}

How to get post

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

with a sigle query?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号