Skip to main content

The : Prefix

All OmniQL queries start with a colon (:).
:GET User WHERE id = 1

Why the Prefix?

OmniQL and native SQL share many keywords (CREATE, UPDATE, SELECT). The prefix acts as a switch, telling the system exactly how to handle the string.
QueryBehavior
:GET User...✅ Parsed and translated to target DB
SELECT * ...❌ Error - missing : prefix
All queries must use OmniQL syntax. For native database commands, use your database driver directly.

Parser Behavior

The oql.Parse() function uses this prefix to determine if it should engage the compiler.
import "github.com/omniql-engine/omniql"

// 1. OmniQL Query (Starts with :)
query, isOQL, err := oql.Parse(":GET User WHERE id = 1")
// isOQL = true
// query = *models.Query (AST)

// 2. Query without prefix = Error
query, isOQL, err := oql.Parse("SELECT * FROM users")
// isOQL = false
// client.Query() will return error: "OmniQL syntax required"

Syntax Pattern

An OmniQL command follows this structure:
:OPERATION Entity [clauses]
PartDescriptionExample
:Required Prefix:
OPERATIONAction to performGET, CREATE, UPDATE, DELETE
EntityTarget Table/CollectionUser, Product, Order
[clauses]Optional modifiersWHERE, ORDER BY, LIMIT

Entity Naming

OmniQL uses PascalCase entity names. The translator automatically lowercases and pluralizes them:
You WriteOutput
Userusers
Productproducts
OrderItemorderitems
Note: The engine lowercases then pluralizes. It does not add underscores (snake_case).

Examples

-- Queries
:GET User WHERE age > 21
:GET id, name, price FROM Product WHERE active = true

-- Mutations
:CREATE User WITH name:"John", age:30
:UPDATE User SET verified:true WHERE id = 1
:DELETE User WHERE status = "inactive"

-- Schema DDL
:CREATE TABLE User WITH id:AUTO, name:STRING, email:STRING
:CREATE INDEX idx_email ON User (email)

Next Steps