Reputation: 155
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?
Upvotes: 0
Views: 90
Reputation: 707
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}})
Upvotes: 1
Reputation: 8004
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}}})
Upvotes: 0