M
M
microf2015-02-01 15:58:03
MongoDB
microf, 2015-02-01 15:58:03

Can you help me understand mongodb?

For a hobby, I decided to look at a bunch of MongoDb, node.js and angular.js. And I got stuck about the lack of understanding of NoSql, in particular mongo.
I need a user profile (for example, the UserProfile collection) to contain completed templates (also stored in separate collections)
in the case of Mysql, I would have a
Table with the name of the templates
id, template_name
A table with template fields
id, template_id, template_field
A table with possible template field fillings (for example, options , for select)
id, template_field_value_name, template_field_id
I would take it - output it to the form and then put it into the table UserTemplate
( id, user_id, template_id) - to display user templates and
( id, user_id, field_id, template_field_value_id) - to display filled template fields.
What to do in case of mongoDb?
I have some kind of collection - a template (you need to create it for each template, right?)
Although, probably, you can put all the templates into one collection (template1: {}, template2)

{template_name : 'Good template', {'field1': {value1,value2,value3},field2:{value1, value2, value3}}

I output this template to the form and save it to the UserProfile collection
{name: 'Ivan', template1: {'field1':'value', field2: 'value'}, 'template2: {...}}

Is that how it works?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yuri Shikanov, 2015-02-01
@dizballanze

You seem to have encountered a typical decomposition problem in nosql. It is necessary to decide depending on how this data will eventually be used. If in the end you will often pull out the entire collection, then it makes sense to put all the data in the UserProfile (if the data is not more than 16MB per document).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question