Query Language (WOQL)
Web Object Query Language — datalog-based query and update language
Part of: Query
62 pages
Explore a Real Dataset — Star Wars Tutorial
Clone, query, branch, and diff a Star Wars database in 15 minutes. Learn TerminusDB's git-for-data workflow on real data.
Explore an Ecommerce Dataset
Clone an ecommerce database, query orders across customers, branch to update an order status, and see the structural diff — in 15 minutes.
How to query with datalog (WOQL)
Hands-on learn by doing tutorial to learn the WOQL Datalog language with working JavaScript examples
Learn WOQL: An Interactive Tutorial
A hands-on interactive tutorial that teaches the WOQL query language from first principles, with runnable examples you can edit and execute against your local TerminusDB instance.
Python WOQL Customer Data Processing Example
A guide to show how to perform basic document queries using the Python Client for customer management.
RDF List Queue Tutorial
Build a task queue using RDF list operations in TerminusDB with step-by-step examples.
Tutorial 1: Dates, Comparisons & Range Queries
Hands-on tutorial using the WOQL Playground to learn date representation, comparison predicates, half-open range filtering, and the as-of vs period query pattern.
Tutorial 2: Durations, Month Arithmetic & Sequences
Hands-on tutorial using the WOQL Playground to learn duration arithmetic, EOM preservation, sequence generation, weekday extraction, and month boundary predicates.
Tutorial 3: Intervals & Allen's Temporal Algebra
Hands-on tutorial using the WOQL Playground to learn interval construction, deconstruction, and Allen's 13 temporal relations for verifying how periods relate to each other.
Tutorial 4: Creative Temporal Patterns
Hands-on tutorial using the WOQL Playground to solve real business problems by exploiting WOQL's logic-programming nature — generators, matchers, unification, and composition of temporal predicates.
WOQL Basics — Pattern Matching and Graph Traversal
WOQL is TerminusDB's Datalog-based query language for pattern matching, graph traversal, and data transformation. Learn the basics with worked examples.
WOQL Getting Started
Examples to Get Started with the TerminusDB Web Object Query Langauge (WOQL)
Edit Documents using WOQL
A guide with example showing how to edit documents using WOQL
Execute WOQL JSON-LD Queries Directly
How to run raw WOQL JSON-LD queries with the JavaScript client, enabling access to new server features before client library support
How to add and delete documents and subdocuments using WOQL
A how-to guide with an example showing how to add documents and subdocuments using a WOQL query.
How to compare values with a CSV file using WOQL
Learn how to efficiently compare a list of values against a CSV file to find additions, deletions, and unchanged items using WOQL
How to delete documents using WOQL
A how-to guide showing how to construct a WOQL query to delete documents.
How to extract tabular data from JSON with WOQL
Learn how to extract rows and columns from JSON arrays using the sys:Dictionary pattern and dot operator in WOQL
How to filter with WOQL
A guide showing how to filter with WOQL in your TerminusDB projects
How to Group Results in WOQL
A guide to show how to group results of data in your TerminusDB projects using WOQL.
How to Order Results in WOQL
A guide to show you how to order results using order_by in WOQL.
How to use the terminusdb CLI query interface
Quick introduction to the terminusdb CLI WOQL Query interface which has a distinct syntax to other flavours.
Import JSON-LD Documents with WOQL
TerminusDB stores data as RDF triples and presents it as JSON-LD. This guide shows how to load existing JSON-LD from files, APIs, or other sources using the Document API or WOQL.
Mathematical Operations in WOQL
A guide to show how to how to perform mathematical operations using WOQL
Path Queries in WOQL
A guide to show how to do path queries in WOQL for your TerminusDB projects.
Queries between Data Products
Learn how to use datalog with knowledge graphs in data products to encode data in a way that resembles the real world, and easily query and manipulate it.
Query Arrays and Sets with WOQL
A guide to show how to query arrays and sets with WOQL in your TerminusDB projects.
Read documents with WOQL
A guide to show how to read documents with WOQL in your TerminusDB projects.
Run a WOQL Query using the JavaScript Client
A quick example to show you how to run a query using WOQL.
Run a WOQL Query with the Python Client
This how-to guide provides an example of the WOQL query language using the Python client
Schema Queries with WOQL
A guide to show how to query schema with WOQL in your TerminusDB projects.
Subdocument Handling with WOQL
A comprehensive guide to creating, reading, updating, and deleting subdocuments using WOQL queries in TerminusDB.
WOQL Tips and Tricks
Practical tips and tricks for writing robust WOQL queries, including handling optional bindings, debugging techniques, and query composition patterns.
Working with Data in WOQL
A practical guide to WOQL's data types, variable binding, solutions, typecasting, dicts, lists, group_by, CSV and JSON conversion, and how backtracking drives result generation.
Allen's Interval Algebra and ISO 8601 Intervals
Guide to Allen's Interval Algebra in WOQL — covering the xdd:dateTimeInterval type, typecasting between inclusive and half-open intervals, all 13 Allen relations, interval classification, and converting between reporting durations and temporal intervals.
End-of-Month Preservation Rules
Complete reference for TerminusDB's end-of-month (EOM) preservation rules — the financial convention for month-based duration arithmetic that keeps month-end dates on month-end boundaries.
ISO 8601 Time Processing in TerminusDB
Learn to process dates, times, durations, and intervals accurately in TerminusDB. Four progressive tutorials cover everything from basic date comparison to creative temporal pattern-solving for financial reporting and scheduling.
Range Queries with triple_slice and quad_slice
How to use triple_slice and quad_slice for fast range queries on typed values in TerminusDB, with automatic type inference from the schema
RDF List Access Operations
Learn how to read elements from RDF lists using peek, member, length, list, and slice operations in WOQL.
RDF List Creation Operations
Learn how to create empty RDF lists and check if lists are empty using WOQL library functions in TerminusDB.
RDF List Modification Operations
Learn how to add, remove, and modify elements in RDF lists using push, pop, append, insert, drop, and clear operations in WOQL.
RDF List Transformation Operations
Learn how to reorder RDF lists using swap and reverse operations in WOQL for TerminusDB.
TerminusDB Data Types
Comprehensive reference for all data types supported in TerminusDB, including XSD, RDF, XDD extensions, and System types.
TerminusDB Path Query Reference Guide
A reference guide to path queries in TerminusDB.
useTDBDocuments hook
useTDBDocuments is the main hook to connect @terminusdb/terminusdb-documents-ui with the TerminusDB server
WOQL Class Reference Guide
The JSON-LD definition of the WOQL language
WOQL Control Flow: Backtracking, Scope, and Performance
Deep guide to WOQL's execution model — how backtracking generates solutions, how variable scope works across sub-queries, and how to structure queries for optimal performance with triple, triple_slice, and streaming results.
WOQL ISO8601 Time and Date Handling
Complete guide to WOQL date, time, duration, and interval handling — ISO 8601 types, comparators, sequences, Allen's Interval Algebra, and financial EOM rules.
WOQL RDF List Operations
Comprehensive guide to working with rdf:List structures in TerminusDB using WOQL library functions for list manipulation.
WOQL Set Operations Reference
Reference guide for WOQL set operations including set_difference, set_intersection, set_union, set_member, and list_to_set
WOQL Variable Generation Guide (Javascript)
Complete guide to the four variable generation methods in the TerminusDB JavaScript client - vars, vars_unique, Vars, and VarsUnique - with practical examples and use cases
Choosing a Query Interface: WOQL, GraphQL, or HTTP API
Compare TerminusDB's three query interfaces — HTTP Document API, GraphQL, and WOQL — and decide which to use for your workload.
How WOQL Finds and Streams Solutions
Understand how TerminusDB's Datalog engine uses goal-seeking backtracking to find solutions in the knowledge graph, how results can be collected or streamed as ndjson with chunked transfer encoding, and when to use each approach.
The WOQL Query Language, Explained
WOQL (Web Object Query Language) is TerminusDB's declarative Datalog-based query language. Traverse document relationships without JOINs, branch-aware, with built-in unification.
What is Datalog?
Datalog is a declarative query language for graph databases. Learn what Datalog is, how it compares to SQL, and why it excels at recursive queries.
What is unification?
Understand unification of variables, a unique and powerful datalog concept included in TerminusDB
Cookbook: Leveraging Arrays with WOQL
Learn to query and manipulate TerminusDB multidimensional arrays using WOQL patterns for efficient data access and processing
Cookbook: Taxonomy Inheritance and Property Inheritance
Learn how to implement value inheritance and property inheritance in hierarchical data structures, including product taxonomies and legal entity relationships
Query Errors — TerminusDB Troubleshooting
Fix common WOQL and GraphQL query errors in TerminusDB including the anyuri vs string type mismatch, unbound variables, empty results, and path query syntax issues.
TerminusDB Query Cookbook
Guides showing how to query using GraphQL, WOQL and in other ways
WOQL Cookbook: Finding and matching datatypes
Examples of WOQL query patterns with datatypes using the WOQL datalog type_of() in three different ways
WOQL Cookbook: Pattern generation
Examples of WOQL pattern generation using substr(), sequence(), weekday(), date arithmetic, interval algebra, range operations, and other predicates that generate all possible solutions via backtracking.