0

I'm using MongoKit as ODM framework. I have object User:

class User(Document):
    __collection__ = 'users'
    ...

There is no __database__ here - I'm using different ones depend on current profile (development, testing etc.) I use queries like this to access data:

app.db.User.one({'email_confirmation_token.hex': token_hex})

It works fine. Now I need to use find_and_modify command. According to documentation, I should call this method from collection to get dict or from object to get object.

This call works:

app.db.users.find_and_modify({'email_confirmation_token.hex': token_hex}, {'$set': {'active': True}})

but this - doesn't:

app.db.User.find_and_modify({'email_confirmation_token.hex': token_hex}, {'$set': {'active': True}})

Error message is: AttributeError: 'CallableUser' object has no attribute 'find_and_modify'.

Why it doesn't contain this attribute?

Marboni
  • 2,399
  • 3
  • 25
  • 42

1 Answers1

1

find_and_modify() is missing in the source code, despite being documented. Try this:

app.db.User.collection.find_and_modify({'email_confirmation_token.hex': token_hex}, {'$set': {'active': True}})