| Features | Comment |
|---|---|
| MongoDB Driver | PyMongo |
| Using ODM | No |
| Transaction Support | No |
| Microservices Support | No |
This repo uses pymongo driver to connect to MongoDB. This repo contains three parts
- Django StartProject rest_api_template
- Orders App
- Shared Python Module
This python module contains three python files each does its own part of the job.
- database.py:
- This file contains the logic to instantiate the pymongo client
- Classes
MongoDBClientsingleton class that extendsObjectclass,Collectiona static class that hasMongoDBClientinstance which creates collection based on Database name and collection name dynamically - It also has
OrderCollectionandProductCollectionclasses which creates singleton classes that usesCollectionclass to get the collection pointer for the database
- helper.py:
- This file mostly will have helper functions that makes our life easier
- wrapper.py:
- This file is created to house Helper classes to create Success or Failure responses
- This file contains three classes
Wrapperclass which has a data field to be set by the extending/implementing classesSuccessWrapperclass is used to build success responses,the data is provided by user, thesuccess=Trueis given in the constructorFailureWrapperclass is built for error messages only
- Orders app contains the typical api logic with models, views and urls. It also has
custom_exceptions.pyfile. - It contains two classes
DatabaseInitExceptionandRecordNotFoundexceptions classes. Both extendsExceptionclass. models.pyfile contains the type definitions forOrderandProduct. Usedmypylibrary to have the typesutil.pyfile contains the actual logic in which the app contacts the database file from shared python module