API Reference

Complete reference for query2jz's API, configuration, and CLI commands.

REST API Endpoints

query2jz automatically generates REST endpoints for all your models.

Query Data

GET

Retrieve data from your models with filtering, sorting, and pagination.

Endpoint

GET /api/query2jz/:model

Query Parameters

whereFilter conditions (JSON)
orderBySort field and direction
limitNumber of records to return
offsetNumber of records to skip
includeRelated models to include

Example

GET /api/query2jz/User?where={"status":"active"}&orderBy=createdAt:desc&limit=10&include=posts

// Response
{
  "data": [
    {
      "id": "1",
      "name": "John Doe",
      "email": "john@example.com",
      "status": "active",
      "posts": [
        { "id": "1", "title": "Hello World" }
      ]
    }
  ],
  "meta": {
    "total": 1,
    "limit": 10,
    "offset": 0
  }
}

Create Data

POST

Create new records in your models.

Endpoint

POST /api/query2jz/:model

Request Body

{
  "name": "John Doe",
  "email": "john@example.com",
  "status": "active"
}

Response

{
  "data": {
    "id": "1",
    "name": "John Doe",
    "email": "john@example.com",
    "status": "active",
    "createdAt": "2024-01-01T00:00:00Z",
    "updatedAt": "2024-01-01T00:00:00Z"
  }
}

Update Data

PUT

Update existing records in your models.

Endpoint

PUT /api/query2jz/:model/:id

Request Body

{
  "name": "Jane Doe",
  "status": "inactive"
}

Delete Data

DELETE

Delete records from your models.

Endpoint

DELETE /api/query2jz/:model/:id

Response

{
  "success": true,
  "message": "Record deleted successfully"
}