0

I need update my document by inserting {four: five, six: seven} in three

db.collection.findAndModify({
    query: {_id: doc._id},
    update: {
        $set: {one: two, three: {four: five, six: seven}},
        $unset: {eight: ""}
    },
    new: true
}, function(err, data) {

});

I'm using mongojs in node.js and an error occurs.

Thanks.

Community
  • 1
  • 1
fran.tr
  • 1
  • 1
  • What is the error that you're getting? I think you should use something like `'one': 'two'`, and so on. – Rodrigo Medeiros Feb 12 '14 at 01:05
  • # # Fatal error in ../deps/v8/src/api.h, line 297 # CHECK(allow_empty_handle || that != __null) failed # and dozens of more lines... – fran.tr Feb 12 '14 at 01:13
  • 4
    I think you should edit your question and add more of your code, and the error stack too. For example, what kind of object is `doc`? – Rodrigo Medeiros Feb 12 '14 at 01:29
  • That does not matter. If I replace `{four: five, six: seven}` for `four`, it works. – fran.tr Feb 12 '14 at 10:38
  • Well, I've tried and was able to replicate a similar cenario, and it worked. I've had to guess what the values of the variables were, so I just used `two = 'two'`, `five = 'five'` and so on. And I had to use an alternative to the `doc._id`, like `mongojs.ObjectId('52fb9a126893e9e4479f06ab')`. The object was changed, as expected, to something like `{ "_id": ObjectId("52fb9a126893e9e4479f06ab"), "one": "two", "three": { "four": "five", "six": "seven" } }`. – Rodrigo Medeiros Feb 12 '14 at 16:20
  • Thank you very much for checking it. What you say made me think and I've found the problem. I was trying to insert an object instead of a string in `six`. – fran.tr Feb 12 '14 at 21:48

0 Answers0