0

i try to alter an document with 2 operations in one query:

_userstats.update(
    {"nick" : nick},
    {"$set" : {"online" : True}},
    {"$inc" : {"joined" : 1}})

But when i try this, i get en error:

raise TypeError("upsert must be an instance of bool")
TypeError: upsert must be an instance of bool

I dont get this to work. Can someone please help me to figure out what exactly my fault is?

knusperwurst
  • 145
  • 3
  • 13
  • You can find your answer here: http://stackoverflow.com/questions/5055797/pymongo-upsert-throws-upsert-must-be-an-instance-of-bool-error-is-this-a-bug – Syed Habib M Nov 15 '13 at 13:56

2 Answers2

1

You should put all update operations in one dictionary passed as second argument to update:

_userstats.update(
    {"nick" : nick},
    {"$set" : {"online" : True}, "$inc" : {"joined" : 1}})
Esenti
  • 707
  • 6
  • 12
0

You are passing the second operation as a third argument, which is not the way update function works. You should put all the operations in one object. Try this:

_userstats.update(
    {"nick" : nick},
    {{"$set" : {"online" : True}},
     {"$inc" : {"joined" : 1}}})
Eser Aygün
  • 7,794
  • 1
  • 20
  • 30