Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to define a MongoDB schema using Motor?

There is a way to define MongoDB collection schema using mongoose in NodeJS. Mongoose verifies the schema at the time of running the queries.

I have been unable to find a similar thing for Motor in Python/Tornado. Is there a way to achieve a similar effect in Motor, or is there a package which can do that for me?

like image 388
chaudharyp Avatar asked Nov 17 '25 12:11

chaudharyp


1 Answers

No there isn't. Motor is a MongoDB driver, it does basic operations but doesn't provide many conveniences. An Object Document Mapper (ODM) library like MongoTor, built on Motor, provides higher-level features like schema validation.

I don't vouch for MongoTor. Proceed with caution. Consider whether you really need an ODM: mongodb's raw data format is close enough to Python types that most applications don't need a layer between their code and the driver.

like image 65
A. Jesse Jiryu Davis Avatar answered Nov 19 '25 01:11

A. Jesse Jiryu Davis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!