Help With Interrelated Data Files for MongoDB?
porgeet

porgeet @porgeet

About: Graphic/digital designer diving into the world of development to be able to make cool sh*t.

Location:
UK
Joined:
Sep 28, 2019

Help With Interrelated Data Files for MongoDB?

Publish Date: Sep 29 '19
2 0

Hi all 👋

I have been wrestling with this issue for ages and getting slightly closer, but the progress is painfully slow. Hopefully someone can help me... 🙏

How can I write interrelated data populate a mongodb database?

Here's an example, I have a series of JavaScript files:

Weapon File - (to go to weapon collection)

[
    {
    name: "Sword",
    damage: 8,
    damageType: ObjectID
    }
]

Damage Type File (to go to damage type collection)

[
    {
    name: "Slicing",
    weapons: [ObjectID, ObjectID]
    }
]

Where ObjectID would refer to the _id of the interrelated data. In this case a weapon would have a damageType and a Damage Type would have a series of weapons.

How would I write those javascript files since the _id field is generated by mongodb?

Any help would be greatly appreciated 😄

Cheers
Pete

Comments 0 total

    Add comment