Answer the question
In order to leave comments, you need to log in
Which one to query mongodb?
{
nick: 'testNick',
params: [{
nick2: 'testNick2',
unique: true
}, {
nick2: 'testNick3'
}]
}
{
nick: 'testNick',
params: [{
nick: 'testNick2',
unique: true
}]
}
Answer the question
In order to leave comments, you need to log in
Make such a structure that it is easy and fast to write / read data (if you want it to work efficiently on big data).
For example, in your case:
_id: 'testNick' - gives uniqueness by nick within the collection (and uses the main index on the case, no need to create an additional index - saves memory).
'nick2.testNick2': true - using a dictionary instead of an array gives uniqueness within the document.
Multiple invocation of the command does not create duplicates.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question