LIMP depends on MongoDB as the database engine of choice. This become the de facto option for LIMP the more the features of MongoDB got updated and improved towards modern apps designs. LIMP handles all necessary functions of MongoDB database bound to LIMP apps using Data Controller object which is locates at https://github.com/masaar/limp/data.py and uses Motor
"Asynchronous Python driver for MongoDB". The Data Controller has the following methods:
create_conn
: This method requests for a new connection to be initialised.read
: This methods takesenv, collection, attrs, extns, modules, query, skip_process
as args and attempts to process LIMPquery
and generate MongoDB-acceptable query and make the call. The method also process the results of MongoDB query for further uniformity with LIMP.watch
: This isread
method withwatch
mode. The method itself is an async Python generator that uses MongoDB nativeChange Streams
feature to watch a collection, docs, or single doc for changes and yields the processed results back toBaseModule
then toBaseMethod
create
: This method takesenv, collection, attrs, modules, doc
and creates a MongoDB doc with contents fromdoc
.update
: This method takesenv, collection, attrs, modules, docs, doc
and use MongoDB update call to update list ofdocs
with contents fromdoc
.delete
: This method takesenv, collection, attrs, modules, docs, strategy
and use MongoDB update or delete calls to flagdocs
as deleted, or actually delete them. Learn more aboutDelete Strategies
in API reference forCall
.drop
: This method takesenv, collection
and uses MongoDB drop call to drop the collection from the database.
Additionally, it has set of methods for internal use which are:
_compile_query
: Top-tier entry point for processing LIMP query into MongoDB query. This methods strips the special query attrs from LIMP query, prepares reference lists for use across the loop generated by_compile_query_step
._compile_query_step
: This method get called from_compile_query
after processing special query attrs and preparing the reference lists. This method iterates over LIMP query object and process every part of it for MongoDB-acceptable aggregate query._process_results_doc
: This method takes in native Python dict as MongoDB doc and processes it using LIMP Attrs Types, as well as wrap it asDictObj
object.
Data Controller is meant to be used internally only. It's considered a security issue for LIMP modules to access Data Controller directly, as at this level there are no privileges to stop users from accessing data they are not supposed to. The explanation of Data Controller in this article is meant as reference only for what this part of LIMP is doing.