Why do I get nedb error "You cannot mix modifiers and normal fields" on update

40 Views Asked by At

I try to update an nedb document using basically the following code:

  var doc =   {
        "$set": {
            "freimessen.messungen": [
                {
                    "Intervall": "kein",
                    "messvorlage": 9,
                    "startzeit": "2021-04-21T16:00:00.000Z",
                    "gaspruefer": 1,
                    "kommentar": "Bitte sorgfältig messen :)",
                    "nummer": 1,
                    "befahrungid": 75,
                    "csenummer": "EPTW-00075-01",
                    "cseid": "288"
                }
            ],
            "status": {
                "id": 3,
                "name": "Messungen beauftragt"
            }
        }
    };

var idobj = { 'id': 35 };

mydb.update(idobj, doc, {}, function (err, numreplaced) {
                   // error handling
                });

But nedb complains: You cannot mix modifiers and normal fields

what is wrong with the update document? I want to update the whole array in the field freimessung.messungen. All items need to get a new field "befahrungId", so I basically read the document, add befahrungId to every item in the array and update, but that does not seem to work this way.

Do I really need to update each array item individually?

0

There are 0 best solutions below