@wxn0brp/vql
    Preparing search index...

    Language Overview

    VQL provides two interchangeable query syntaxes that compile to the same internal representation.

    Syntax Format Best For
    VQLS String CLI, configs, quick scripts
    VQLR Object Programmatic use, TypeScript
    Operation VQLS VQLR Key Description
    find db collection find Find multiple records
    findOne db collection! findOne / f Find single record
    add db +collection add Insert record
    update db ~collection update Update matching
    updateOne db ~collection! updateOne Update single
    remove db -collection remove Delete matching
    removeOne db -collection! removeOne Delete single
    updateOneOrAdd db ?collection updateOneOrAdd Upsert
    toggleOne db ^collection toggleOne Add/remove toggle
    count db #collection count Count matching records
    bulkAdd db *collection bulkAdd Insert multiple records
    ensureCollection db ensureCollection name ensureCollection Create if not exists
    issetCollection db issetCollection name issetCollection Check exists
    removeCollection db removeCollection name removeCollection Delete collection
    getCollections db getCollections getCollections List collections
    Prefix Purpose VQLR Key
    s. Search/filter search
    d. Data (for add) data
    u. Update payload updater
    o. Options (limit) options
    r. Relations relations
    e. Field selection select
    Operator Meaning Example
    = Equal s.age=25
    > Greater than s.age>18
    >= Greater or equal s.age>=18
    < Less than s.price<100
    <= Less or equal s.price<=100

    Inject dynamic values into queries.

    Variable Value
    _me user.id || user._id || user
    _user Full user object
    _now Date.now() (ms)
    _nowShort Math.floor(Date.now() / 1000) (s)
    __now Date.now().toString()
    __nowShort Seconds as string

    VQLS - $variableName in values:

    db users s.role=$role d.createdAt=$_now
    

    VQLR - { __: "variableName" } for references:

    { data: { ownerId: { __: "_me" }, createdAt: { __: "_now" } } }
    

    Pass custom variables:

    // VQLS with vars
    await processor.execute({ query: `users s.role=$role`, var: { role: "admin" } });

    // VQLR with vars
    await processor.execute({ db: "main", d: { find: {...} }, var: { custom: "val" } });
    import type { VQLUQ, VQL_Query, VQL_Query_CRUD } from "@wxn0brp/vql";

    const q1: VQLUQ = `users s.status="active"`;
    const q2: VQLUQ = { db: "main", d: { find: { collection: "users" } } };