MongoDB - manual references example -


i reading manual references part mongodb database references documentation, don't understand part of "second query resolve referenced fields". give me example of query, can better idea of talking about.

"manual references refers practice of including 1 document’s _id field in document. application can issue second query resolve referenced fields needed."

the documentation pretty clear in manual section referring section on database references. important part in comprehending contained in opening statement on page:

"mongodb not support joins. in mongodb data denormalized, or stored related data in documents remove need joins. however, in cases makes sense store related information in separate documents, typically in different collections or databases."

the further information covers topic of how might choose deal accessing data store in collection.

there dbref specification without going more detail, may implemented in drivers way when these found in documents automatically retrieve (expand) referenced document current document. implemented "behind scenes" query collection document of _id.

in case of manual references saying there merely field in document has it's content objectid document. differs dbref never processed base driver implementation leaves how handle further retrieval of other document soley you.

in case of:

> db.collection.findone()  {    _id: <objectid>,    name: "this",    something: "else",    ref: <anotherobjectid> } 

the ref field in document nothing more plain objectid , nothing special. allows submit own query object details refers to:

> db.othercollection.findone({ _id: <anotherobjectid > }) {   _id: <objectid>   name: "that"   something: "i sub-document this!" } 

keep in mind of processes on client side via driver api. none of fetching other documents happens on server in case.


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -