Sign In Register

How can we help you today?

Start a new topic

Documentation on SparkMongoCollectionReadWrite.update() says upsert = false, getting new records in DB

According to this:

update() has two parameters and acts like mongoDB update() but passes in upsert=false.

I am getting new documents when using this function.

As an example:

var  query = { 

                    mapId: mapData[i].mapId,

                    id: mapData[i].id,

                    updatedTs: new Date(mapData[i].updatedTs)


Spark.runtimeCollection('kmHexGroup').update(query, {dirty: false});

Is returning the error: 

Write failed with error code 11000 and error message 'E11000 duplicate key error index: 303656-game-preview.script.kmHexGroup.$Primary Key dup key: { : null, : null }' (modules/KingdomMapUtil.js#136)

This is because I somehow got an (nearly) empty object in the DB:

 "_id": {
  "$oid": "58210a24b6a70d055bb32f03"
 "dirty": false

Hi Christopher,

I'll have the documentation team review this and get it updated if required.



Hi Liam,

I think I was using the update() command wrong. I wasn't using the $set operator, so the entire document was getting overwritten (with null MapId)

Login to post a comment