Overview

jQL (Jeli Query Language) is how jDB performs table operations, calls REST APIs registered with a database, and drives its own environment — all through a single method: db.jQl(query, params).

db.jQl(query, params) → Promise
ArgumentTypeRequiredNotes
querystring | object | arrayYesA single command (string or object), or an array of them to run in sequence.
paramsobjectNoValues substituted into %key% placeholders inside a string query.

Every command — insert, select, drop, and so on — is a plugin registered with its own schema: a declared set of fields with names, optional types, defaults and flags. The schema is what makes both syntaxes below, and the object form, resolve to exactly the same thing.

Deprecated: db.jQl(query, handler, params) (a second {onSuccess, onError} argument) still works but logs a deprecation warning. Use the returned Promise instead.

Two syntaxes, one schema

jDB detects which syntax a string query uses automatically — nothing to configure, and the two can be mixed freely across calls.

v1  Positional flags

The original syntax: a command name followed by -value tokens. Non-flag fields are matched by position; boolean fields are matched by typing their name as a bare word anywhere in the query.

insert -{"name":"Ada","role":"admin"} -users -ignoreSync -hard
v2  Named flags

A newer --name=value / bare --name syntax. Fields are matched by name instead of position, so flags can appear in any order. jDB only treats -- as a flag boundary outside quotes/braces and immediately before a letter, so JSON data containing a dash ({"score": -5}) is never misread — that exact ambiguity is why v1 requires care with values containing  -.

insert --data={"name":"Ada","role":"admin"} --table=users --ignoreSync --hard
Object form

Skip string parsing entirely by handing jQl a plain object with a command key. This is the most robust option for code generating queries programmatically.

db.jQl({
    command: 'insert',
    table: 'users',
    data: { name: 'Ada', role: 'admin' },
    ignoreSync: true
});

Field types

Each command's fields table below lists a type badge where the command validates that field. A field with no badge accepts anything it's given (its shape legitimately varies — e.g. insert's data is an object for a single record or an array for a bulk insert).

BadgeMeaning
stringTaken literally, never coerced — a table named "123" stays the string "123", not the number 123.
booleanMust resolve to true/false; anything else is rejected with a clear error.
numberMust resolve to a number.
objectMust resolve to a plain object.
arrayMust resolve to an array.
flagA boolean toggle: typing its name (v1) or --name (v2) sets it true; leaving it out resolves to false. Never a mismatch error — there's no value to validate.
A type mismatch (e.g. passing "nope" where a command expects an object) rejects the query with a message naming the field and the expected type, before the command ever runs.

Response shape

On success, most commands resolve with:

{ state: "insert", status: "success", result: { message: "..." }, code: 200 }

On failure, the promise rejects with:

{ message: "...", status: "error", code: 400 }

select resolves with a result set object exposing getResult() and jDBNumRows() instead of a plain message.

Table

create

create -table -columns
FieldPositionTypeNotes
table1stringTable name.
columns2arrayOptional — array of column definitions. Omitted defaults to [].
create -users -[{"id":{"type":"NUMBER","AUTO_INCREMENT":1},"email":{"type":"VARCHAR"}}]

alter v1 only

alter -table -action -...args
FieldPositionTypeNotes
table1string
action2stringa add, d drop, r rename, u update mode.
...args3+Meaning depends on action — see below.

When action is a (add), the next argument selects what's being added:

Sub-actionAddsRemaining args
ccolumncolumn name, config object
pprimary keycolumn name
fforeign keycolumn name, relative table
iindexconfig object
mread/write modemode
alter -users -a -c -fullName -{"type":"VARCHAR","defaultValue":"Foo Bar"}
alter -users -d -fullName
alter -users -r -people
v2 (--name=value) syntax isn't supported for alter yet. Its trailing arguments are positional by meaning (sub-action, then column, then config), and named syntax has no positional-order concept to map them from. Use v1 or the object form for alter until it gets its own named fields (e.g. --subAction=c).

truncate

truncate -table -flag
FieldPositionTypeNotes
table1string
flag2"yes"/"no" or a boolean — must be truthy to actually run.
truncate -users -yes

truncate-db

truncate-db -dropFromServer
FieldPositionTypeNotes
dropFromServer1booleanOptional.

Truncates every table in the current database.

drop

drop -type -name -flag -localOnly
FieldPositionTypeNotes
type1stringt table, d database.
name2stringTable or database name.
flag3"yes"/"no" or a boolean — must be truthy to actually run.
localOnly4booleanDatabase drops only.
drop -t -users -yes
drop -d -myapp -yes -true

Transactions

insert

insert -data -table
FieldPositionTypeNotes
data1Object for a single record, or an array of objects for a bulk insert.
table2string
replace—flagUpsert by the table's primary key instead of a plain insert.
hard—flag
skip—flagSkip data processing/validation.
ignoreSync—flag
rollbackOnError—flag
insert -[{"name":"Foo Bar","email":"foo@bar.com"},{"name":"Bar Foo","email":"bar@foo.com"}] -users

update

update -table -data -cond
FieldPositionTypeNotes
table1string
data2objectFields to set.
cond3Condition expression. Omit to update every row.
ignoreSync—flag
rollbackOnError—flag
update -users -{"role":"admin"} -age>18

updatemany

updatemany -table -data
FieldPositionTypeNotes
table1string
data2arrayArray of [cond, data] pairs, one update per pair.
updatemany -users -[[{"age":18},{"role":"admin"}]]

delete

delete -table -cond -ignoreSync
FieldPositionTypeNotes
table1string
cond2Condition expression. Omit to delete every row.
ignoreSync3booleanPositional, not a bare flag, on this command.
rollbackOnError—flag
delete -users -age>18 -true -rollbackOnError

select

select -fields -table -...clauses
FieldPositionTypeNotes
fields1string*, a comma-separated list, or col as alias.
table2stringComma-separated for multiple tables (e.g. joins).
...clauses3+join(...), where(...), limit(...), orderBy(...), groupBy(...) — any number, any order.

Condition operators inside where(...):

OperatorMeaning
===is
== / =equals
>= > <= <comparison
!=not equal
!== is not
~like
[] / ![]in array / not in array
[=] / [!]in clause / not in clause (subquery)
v1
select -* -users -where(role~admin) -limit(10) -orderBy(name)
v2
select --fields=* --table=users --where=role~admin --limit=10
Unlike alter, select's clauses are supported under v2: any --name=value not matching fields/table is collected as a clause of that name, so --where=... and --limit=... work exactly like their v1 -where(...) / -limit(...) equivalents.

Join clause: join(@table(t2) @clause(INNER) @on(t1.column=t2.column)), with INNER, LEFT, RIGHT or OUTER. All referenced tables must already exist.

batch

batch -transactions
FieldPositionTypeNotes
transactions1arrayArray of {type, table, data, query, hardInsert} transaction descriptors.
rollbackOnError—flagRoll back the whole batch if any transaction fails.
batch -[{"type":"insert","table":"users","data":{"name":"Ada"}}] -rollbackOnError

Data

import

import -table -fileType -isSchema
FieldPositionTypeNotes
table1string
fileType2stringjson, jql, csv or html.
isSchema3boolean

Opens a file picker. If the table doesn't exist yet, it's created before the data is inserted.

export

export -table -type -action -fileName -title
FieldPositionTypeDefault
table1stringall
type2stringjson (also csv, html, jql)
action3stringprint (d to download)
fileName4string""
title5string""
export -users -csv -d -users-export

sync

sync -table -force -syncData
FieldPositionTypeNotes
table1stringOmit to sync every table.
force2boolean
syncData3
sync -users -true

Environment

schema

schema -action -arg
FieldPositionTypeNotes
action1stringexport or add.
arg2Server flag for export; schema data for add.
schema -export -true
schema -add -{"users":{"type":"create","definition":[{"id":{"type":"NUMBER"}}]}}

env

env -method -arg
FieldPositionTypeNotes
method1stringlogger, resource or usage.
arg2Passed straight to the chosen method.
env -usage

help

help -target
FieldPositionTypeNotes
target1stringOptional — a command name to look up. Omit to list every command's help text.
help
help -insert

api

api -path -data
FieldPositionTypeNotes
path1A route string, or a full request object ({URL, METHOD, AUTH_TYPE, body}).
data2Optional request body.

Calls a REST endpoint registered with the database through the same jQL pipeline as table commands.

api -/set/access/token -{"token":"abc"}

cls

cls

No fields. Signals a command-line/REPL front end (like the playground) to clear its output. Doesn't touch the database.