0

I have create the variable with value index position Card in database.

Problem is here with $set, can someone correct me query with use variable "position" please ???

And can We create query like this??

enter image description here

Because at this moment this query don't work. Can someone help me please?

EDIT

/* 1 */
{
    "_id" : ObjectId("59e0aa31daa273086bf100ae"),
    "name" : "2",
    "users" : [ 
        ObjectId("59cd114cea98d9326ca1c421")
    ],
    "lists" : [ 
        {
            "list" : "1",
            "cards" : [ 
                {
                    "name" : "dea"
                }
            ]
        }, 
        {
            "list" : "dea",
            "cards" : [ 
                {
                    "name" : "22222",
                    "Author" : [ 
                        "59df60fb6fad6224f4f9f22d", 
                        "59df60fb6fad6224f4f9f22d", 
                        "59df60fb6fad6224f4f9f22e"
                    ]
                }, 
                {
                    "name" : "fea"
                }
            ]
        }
    ],
    "__v" : 0
}

/* 2 */
{
    "_id" : ObjectId("59e35de8a8c83d1ab00dfcb9"),
    "name" : "2",
    "users" : [ 
        ObjectId("59cd114cea98d9326ca1c421")
    ],
    "lists" : [],
    "__v" : 0
}
  • can you show me your db schema? also, Please tell me what do you mean by doesnt work?? is it not working while updating or upserting or both? – Ravi Shankar Bharti Oct 15 '17 at 13:07
  • I make edit now – Aneta Jabłońska Oct 15 '17 at 13:11
  • Welcome to Stack Overflow. [You already asked this question](https://stackoverflow.com/questions/46754784/mongodb-cant-create-query-with-dot-notation). It was marked as the same duplicate as this one has been and then you chose to delete it. If you carefully read the answers on the duplicate, they do show you how to **correctly** construct a "variable object key". This is the question you are asking. It's a very common question and has been answered before. So you were pointed there for a reason. Please don't try to circumvent and also realize where you are being pointed to an answer. – Neil Lunn Oct 15 '17 at 13:18

0 Answers0