Mongodb reference

3

I want to make a website. Ira to have two collections "listmangas", where it will be named after several sleeves. "genre", where you will have the genres of type "Action, Comedy"

In the website will have form to enter the name of the anime and checkbox to select the genre.

I wanted to understand how to do this in mongodb and then figure out how to do it on the website.

Insert "gender"

db.genero.insert({genero:"Comedia"})
db.genero.insert({genero:"Ação"})

Insert name in "listmangas"

db.listmangas.insert({nome:"toriko"})

How to reference gender: "Action" in the name: "toriko"?

How to look after the Toriko name of the list mangas and the genre appears: "Action"?

If it was a bit messy, I try to improve that question.

    
asked by anonymous 23.01.2016 / 02:11

1 answer

2

As far as I know, a mongo document assumes a nonrelational model and is defined by a key-value pair set. So for this scenario to be possible, you should add at the same time:

db.listmangas.insert({nome:"toriko", genero:"acção "})

Regarding the second part of the question, here's a nice example on how to do to query.

    
23.01.2016 / 02:19