I need to achieve such collection structure:
{
"_id" : "36JaTS8N9uJDHabaq",
"pages" : {
1 : {
"field1" : "value1",
"field2" : "value2"
},
...
}
}
Everything is fine, when I'm doing the following:
Collection.insert({
"pages": {
1: {
"field1" : "value1",
"field2" : "value2"
}
}
})
But when I'm trying to use the variable containing the number instead of number itself, like:
var number = 1;
Collection.insert({
"pages": {
number: {
"field1" : "value1",
"field2" : "value2"
}
}
})
I receive not the result I want (there is a variable name where number should be):
{
"_id" : "SjMotZHrtXviuoyqv",
"pages" : {
"number" : {
"field1" : "value1",
"field2" : "value2"
}
}
}
What is the right way to do what I'm trying to achieve?
Thanks in advance!