Getting Started with ObjectQL
Getting Started with ObjectQL
ObjectQL is a universal, metadata-driven ORM designed for building dynamic business applications. Unlike traditional ORMs where you define schema in class files (like TypeORM entities), ObjectQL uses a Metadata-First approach.
Why ObjectQL?
- Metadata-Driven: Define your data models in JSON or YAML. Perfect for low-code platforms where schema changes at runtime.
- Universal Protocol: The query language is a JSON AST, making it easy for frontends or AI agents to generate queries.
- Action & Hook System: Built-in support for "Button Actions" (RPC) and "Triggers" (Hooks), allowing you to model Behavior alongside Data.
Quick Start
The fastest way to get started is using the CLI to scaffold a project.
1. Create a New Project
The easiest way to start is using the generator.
This will create a new project with all necessary dependencies.
2. Install VS Code Extension (Recommended) 🚨
To treat your metadata like code (with validation and autocomplete), install the Standard ObjectStack AI Extension.
- Open Visual Studio Code.
- Go to the Extensions view (
Cmd+Shift+X). - Search for
ObjectQLand install. - Alternatively, when you open the created project, VS Code will prompt you to install recommended extensions.
Why? The extension understands your
*.object.ymlfiles, validating field types and relationships in real-time, just like TypeScript.
3. Define the Protocol (Your Meta-Schema)
Instead of passing objects to a constructor, we define them in YAML. This is the "AI-Native" way—separate the Instruction (YAML) from the Execution (Runtime).
Create a file src/objects/todo.object.yml:
4. Run the Project
ObjectQL will detect the new file, generate the necessary database tables (in SQLite by default), and start the server.
5. Manual Setup (Programmatic API)
If you are integrating ObjectQL into an existing specialized backend (like a Lambda function or a custom script), you can use the Programmatic API.
Scaling Up: The Metadata Approach
Once you are comfortable with the basics, notice that standard projects use file-based modules configuration.
Adding Business Logic
ObjectQL shines when you need to add logic.
Adding a Hook
Triggers logic automatically when data changes.
Adding an Action
Defines a custom operation (RPC) that frontends can call.
Next Steps
- Database Drivers: Connect to PostgreSQL, MongoDB, etc.
- Data Modeling: Learn about all field types (Select, Lookup, Date, etc.)
- API Reference: Explore the full API.
- Hooks: Deep dive into the event system.