Standard library - query

Module:

module query

// Types
type ast = data

def cmp : string -> string -> data -> ast
def cmpExpr : string -> ast -> data -> ast

def eq : string -> data -> ast
def neq : string -> data -> ast
def lt : string -> data -> ast
def gt : string -> data -> ast
def le : string -> data -> ast
def ge : string -> data -> ast
def contains : string -> data -> ast
def like : string -> data -> ast
def featuresOne : string -> data -> ast
def featuresAll : string -> data -> ast

def nullFilter : ast
def token : string -> ast

def exists : string -> ast
def afterWatermark : string -> ast
def afterRow : number -> ast
def not_ : ast -> ast
def and : data -> ast    // array(ast) -> ast
def or : data -> ast    // array(ast) -> ast
def invoke : string -> data -> ast   // string -> array(ast) -> ast

def object : data -> ast    // array(ast) -> ast
def cloneMembers : ast
def cloneMembersWithExpansion : ast
def assignMember : string -> ast -> ast
def removeMember : string -> ast
def objectMember : ast -> string -> ast
def followRef : ast -> ast

def scalarFallback : data -> ast
def scalarIndexed : data -> ast
def listFallback : data -> ast
def listIndexed : data -> ast

def count : ast
def group : string -> ast

def filterOfMap : data -> ast
def filterOfMapFallback : data -> ast
def projectionOfMap : data -> ast // object -> ast

module end

Types

  type ast = data

The type ast represents the abstract syntax tree defining our query and projection language. Currently these queries can be applied to the database but soon they will be applicable to plain data as well.

An example:

> db.head() |> db.processPipeline([q.eq("foo", "bar"), q.count])
| .:1:1 (to 1:63): $value : db.query
$value = { data: [ [ "comparison", "==", [ "token", "foo" ], "bar" ], [ "invoke", [ "token", "count" ] ] ], db: "main", includeDeleted: false, includeSuperseded: false, label: "", post: [  ], postFilter: [  ], type: "rmx", unrestricted: false }

ASTs are represented as JSON data in an implementation-defined way. There are a number of helper functions in this module that create ASTs in the right format.

Primary documentation

See Query syntax

AST nodes for filters: