pythonmongodbcrudpymongomongokit

Mongokit add objects to collection


How do you insert objects to a collection in using MongoKit in Python?

I understand you can specify the 'collection' field in a model and that you can create models in the db like

user = db.Users()

Then save the object like

user.save()

However I can't seem to find any mention of an insert function. If I create a User object and now want to insert it into a specific collection, say "online_users", what do I do?


Solution

  • After completely guessing it appears I can successfully just call

    db.online_users.insert(user)