Query

Introduced in 4.2.0

Stability: 1 - Experimental

const Query = require('kado/lib/Query')

The Query class implements a super class for constructing query builders that are customized for a specific query language.

Class: Query

static Query.addBase(table, selection, construct, tableConstruct)

static Query.addComparison(context, construct, item, operator, value, joiner)

static Query.addLimit(construct, start, limit)

static Query.addOrder(context, construct, by, direction, joiner)

static Query.addJoin(query, direction)

static Query.printJoin(table, condition, construct)

static Query.print(base, join, where, order, limit)

Query.constructor(tableName)

Query.toString()

Class: QuerySQL

QuerySQL.constructor()

QuerySQL.on(item, operator, value, joiner)

QuerySQL.select(selection)

QuerySQL.log()

Prints the query to process.stdout via console.log, equivalent of console.log(query.toString(), query.toArray())

QuerySQL.leftJoin(query)

QuerySQL.where(item, operator, value, joiner)

QuerySQL.limit(start, limit)

QuerySQL.order(by, direction, joiner)

QuerySQL.toLeftJoin()

QuerySQL.toString()

QuerySQL.execute(db, options)

This is a convenience method to make executing queries involve less typing.

Original Method

db.execute(query.toString(), query.toArray(), options)

Better Method

query.execute(db)

QuerySQL.run(db, options)

This method calls the mariadb driver db.query() method which returns a different return format from the db.execute() method.