Skip to content

Instantly share code, notes, and snippets.

@AmitDJagtap
Created November 2, 2019 08:37
Show Gist options
  • Save AmitDJagtap/9fdbc12409bbfcc2ca55e7eb6b68c241 to your computer and use it in GitHub Desktop.
Save AmitDJagtap/9fdbc12409bbfcc2ca55e7eb6b68c241 to your computer and use it in GitHub Desktop.
Example 2. Modelling One-to-Many: Reference parent document from child documents
//Primary Collection
[
{
id: ObjectID('AAAA'),
partno: '123-aff-456',
parentCatalogNo: 1234,
name: '#4 grommet',
price: 3.99
},
{
id: ObjectID('AAAA'),
partno: '909-was-356',
parentCatalogNo: 1234,
name: '#12 washer',
price: 0.10
}
]
// Referenced Document
{
name: 'left-handed smoke shifter',
manufacturer : 'Acme Corp',
catalog_number: 1234
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment