Mandarine.TS
Latest
Latest
  • Mandarine.TS
  • Getting started
    • Installing Deno Runtime
    • Setting up Environment
    • Quick Example
  • Concepts
  • Mandarine Project Structure
  • Mandarine CLI
    • CLI Reference
      • mandarine new
      • mandarine generate
      • mandarine run
  • Mandarine Core
    • Core Initialization
    • Mandarine.json
    • Dot env file
    • Properties
      • The @Value Decorator
    • Components
      • Controller
      • Middleware
      • Repository
      • Component
      • Service
      • Configuration
      • Manual Component
    • Dependency Injection
      • Accessing DI container
    • Resource Handlers
      • Resource Handler Registry
      • Resource Handler
      • Resource Resolver
  • Mandarine MVC
    • Web MVC
    • Controllers
      • Routes
        • Parameterized Routes
      • HTTP Handlers
      • @ResponseStatus
    • Custom Middleware
    • Session Middleware
    • CORS Middleware
    • Template Engine
      • @Render Decorator
      • Accessing data from template
    • Launching web-app
    • Serving Static Content
    • Multipart Form Data
  • Mandarine Security
    • Sessions
  • Mandarine Data
    • ORM
      • Data source
      • Models
      • Repositories
        • Interacting with data
        • Updating data
    • Mandarine Query Language
  • Resources
    • Changelog
  • Plugins
    • Optional
    • Promise Repeater
Powered by GitBook
On this page
  • Main
  • The lexical processor
  • MQL Operators
  • Definers
  • General definers
  • "Save" definer
  • Naming conventions

Was this helpful?

  1. Mandarine Data

Mandarine Query Language

Mandarine Query Language (MQL) is a sub-module of Mandarine's repositories. Although, MQL is considered an autonomous submodule.

PreviousUpdating dataNextChangelog

Last updated 4 years ago

Was this helpful?

Understanding of 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 principles & follow MVC patterns as well as making your code as simple and readable as possible.

Note that MQL is written inside

The lexical processor

MQL makes use of a lexical processor that will transform the names of your repositories' methods in SQL & processable queries.

findByAirlineAndPassengerName(airline: string, passengerName: string)

Will be transformed into

SELECT * FROM MyTable WHERE airline = $1 AND passengerName = $2

# MyTable = Table of your model related to your repository 
# $1 = airline parameter
# $2 = passengerName parameter

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

  • IsNotNull

  • IsNull

  • IsNotEmpty

  • IsEmpty

  • StartingWith

  • EndsWith

  • Like

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 rows

  • deleteAll: Delete all rows in entity

  • countAll: Count all rows in entity

  • findBy...: Creates & executes a select query

  • countBy...: Creates & executes a select count query

  • existsBy...: Creates & executes a verification statement

  • deleteBy...: Creates & executes a delete query

"Save" definer

  • 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

  1. Do use camel case

  2. Do not use underscores, or other characters that may affect readability.

  3. The names of your columns must match the name of your parameter in your repository method. Otherwise, query execution will fail.

Although, more operators are planned to be released. .

In order to add () information to your entity in your database, MQL allows you to do so by using save

Mandarine's ORM concepts
SOLID
repositories
Click here for more information
or update
(Click here to see declaration)