jxmono / crud

:fork_and_knife: CRUD for mono
MIT License
0 stars 1 forks source link

$in is not parsed correctly #18

Closed IonicaBizau closed 11 years ago

IonicaBizau commented 11 years ago

I have three items in my MongoDB collection that have the following object ids: 524c3364d1e72e0e1500001d, 524c3365d1e72e0e1500001e, 524c3362d1e72e0e1500001c.

I want to set {parent: "524c3362d1e72e0e1500001c"} for the 524c3364d1e72e0e1500001d and 524c3365d1e72e0e1500001e.

Only one document is updated.

The crud object is:

{
    "q": {
        "_id": {
            "$in": [
                "524c3364d1e72e0e1500001d",
                "524c3365d1e72e0e1500001e"
            ]
        },
        "template": "524c23b1f86133f09db67dfa"
    },
    "d": {
        "$set": {
            "parent": "524c3362d1e72e0e1500001c"
        }
    },
    "t": "000000000000000000000004"
}

...and I make self.emit("update", crudObject, function (err, data) {}).

No error is thrown, but I don't see the expected result.

In mongo shell if I do:

db.d_lists.update(q, d, {multi: true})

I get the correct result.

ottiker commented 11 years ago

And do you send {multi: true} in the crud options?

IonicaBizau commented 11 years ago

Has this parameter to be sent? Where in the o field of crudObj?

ottiker commented 11 years ago

I've testet it with {mutli: true} and it works. See here for more info: http://docs.mongodb.org/manual/reference/method/db.collection.update/#multi-parameter

IonicaBizau commented 11 years ago

Yes, it works. o: {multi: true} was missing from the crud object. Thanks!