Sign In Register

How can we help you today?

Start a new topic

Wrong documentation for SparkMongoCollectionReadWrite.findAndModify()

The example for the last signature for findAndModify is wrong.

The signature is: signature findAndModify(JSON query, JSON fields, JSON sort, boolean remove, JSON update, boolean returnNew, boolean upsert)

and the example is var doc = myRuntimeCollection.findAndModify({"metafield" : "metavalue"},{"metafield" : 1},false,{"metafield" : "metavalue1"},true, {"metafield" : 1},false);

In the example a boolean is included where the JSON for sort is expected and the last 3 arguments don't match at all.

My question is, how do I findAndModify a document with returning the modified document but without sort, upsort etc.?

2 people have this problem

Hi David,

Thanks for bringing this to our attention, we'll look into this and get back to you.



I can't make this work and the documentation is still wrong. Could you please fix it?

The long signature works like this:


var doc = runtimeCollection.findAndModify(
    {"_id": id},         // query
    {},                     // fields
    {},                     // sort
    false,                  // remove
    {"$inc": { "foo": 1}},  // update
    true,                   // return new
    true                    // upsert


Login to post a comment