Answer the question
In order to leave comments, you need to log in
How to properly build a query in MongoDB?
Good evening.
Tell me how to properly extract data from Mongo that has the following structure. There are three collections Contests, Groups, Fields - each of which links to the next one via id:
const Contest = {
...
group_ids: ['abc', 'def']
...
}
const Group = {
...
title: 'Hello'
...
}
const Field = {
...
fieldGroupId: 'abc'
}
const groups = [
{
gruop: GROUP_DATA,
fields: GROUP_FIELDS
},
...
]
let groups = contest.fields_groups.map( async ( group_id ) => {
let group = await ContestGroups.findById( group_id );
let fields = await ContestField.where({ fieldGroupId: group_id });
return {
group: group,
fields: fields
};
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question