Refty / mongo-thingy

:leaves: Powerful schema-less ODM for MongoDB and Python (sync + async)
https://mongo-thingy.readthedocs.io
MIT License
69 stars 12 forks source link

How to specify the collection name of mongodb #13

Closed toplinuxsir closed 6 years ago

toplinuxsir commented 6 years ago

If the collection name dose not match the Thingy class name , How to specify the collection name of mongodb?

ramnes commented 6 years ago

Hey @toplinuxsir,

You can either specify the collection name:

class Foo(Thingy):
    collection_name = "bar" 

or the collection directly:

class Foo(Thingy):
    collection = db.bar

You can then check what collection is being used with:

>>> Foo.collection
Collection(Database(MongoClient('localhost', 27017), 'database'), 'bar')

As you can notice, we really miss a proper documentation, and we're sorry for that. It's our main priority for the upcoming versions.

ramnes commented 6 years ago

Feel free to open another issue if you have any other question @toplinuxsir. 👍