Mandarine Query Language
Mandarine Query Language (MQL) is a sub-module of Mandarine's repositories. Although, MQL is considered an autonomous submodule.
Understanding of Mandarine's ORM concepts is required for this article
Main
Mandarine Query Language (MQL) serves as a helper to write queries. The main objective of MQL is to avoid the writing of SQL queries in your application's layer, and keep everything in a programatic environment. This is because, Mandarine.TS aims to respect SOLID principles & follow MVC patterns as well as making your code as simple and readable as possible.
Note that MQL is written inside repositories
The lexical processor
MQL makes use of a lexical processor that will transform the names of your repositories' methods in SQL & processable queries.
Will be transformed into
MQL Operators
Operators are keywords that will tell the lexical processor what type of operation is being requested at a SQL level.
Currently, MQL only supports the operators
AND
OR
Although, more operators are planned to be released. Click here for more information.
Definers
Definers are keywords that will shape your final SQL query. Definers are used for the lexical processor to identify what type of query is being or will be built.
General definers
findAll
: Select all rowsdeleteAll
: Delete all rows in entitycountAll
: Count all rows in entityfindBy...
: Creates & executes a select querycountBy...
: Creates & executes a select count queryexistsBy...
: Creates & executes a verification statementdeleteBy...
: Creates & executes a delete query
"Save" definer
In order to add (or update) information to your entity in your database, MQL allows you to do so by using save
(Click here to see declaration)
save
is part of a native method of a mandarine repository.save
takes one argument which will be a object of your repository's model with the data to be inserted
Naming conventions
Do use camel case
Do not use underscores, or other characters that may affect readability.
The names of your columns must match the name of your parameter in your repository method. Otherwise, query execution will fail.
Last updated