Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (4k points)

In MongoDB there is a nice tutorial on Manual Reference:

Example:

original_id = ObjectId()

db.places.insert({
    "_id": original_id,
    "name": "Broadway Center",
    "url": "bc.example.net"
})

db.people.insert({
    "name": "Erin",
    "places_id": original_id,
    "url":  "bc.example.net/Erin"
})

Note, that this two documents are created at same time.

Question. I need to reference a Customer with an Order, therefore the Customer has been created long time before the Order, how can I add this reference of customer and insert in Order?

1 Answer

0 votes
by (8.7k points)

You can easily achieve it by using the below command and then adding the respective id to the new document.

findone() 

To explore more about it, Check out the MongoDB tutorial by Intellipaat. 

Related questions

0 votes
1 answer
asked Mar 2, 2021 in Web Technology by adhiraj (4k points)
0 votes
2 answers
asked Sep 4, 2019 in SQL by Sammy (47.6k points)
0 votes
1 answer

Browse Categories

...