Reference in the mongodb

Asked

Viewed 133 times

0

Well, guys, I know there’s no such thing as a relationship, but I need to know how to do something related. I have two collections a call, Extinguisher and the other Historical, I want an extinct has a list of your history, someone could help me, as I would do this, Mongoose Node, React-Native.

1 answer

0

Friend, unlike the Relational Banks, in SGBD Mongodb there is no concept of relationship and yes, reference.

In your context, you can ship the documents contained in the collection extinguisher with an array historical.

But if you want to have two collections, you can:

In the Historical collection, reference the Extinguisher collection. This way, they will be related by the Object ID (primary key) generated by itself, Mongodb;

I don’t know exactly how Mongoose Node works, but I leave this link in order to help:

Link To Reference

Good Luck!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.