REST from your database catalog
    DocumentationCheat sheetQuestionsDownloadSource
    Questions
    • How do I...?
    Start here
    • Getting started
    • What a table becomes
    • Compared with PostgREST
    Setting up
    • Tables, columns and relations
    • Security and hooks
    • Writes and procedures
    • Prefer: return=representation
    • Node, Fastify, Express
    Reading
    • select
    • /{key}
    • relation(...)
    • order
    • limit, offset
    • relation.order, .limit
    • count
    • count(), sum(), avg()...
    • "name"
    Filtering
    • eq, neq
    • gt, gte, lt, lte
    • in
    • like, ilike
    • match, imatch
    • is
    • ov, cs, cd
    • not
    • relation.column
    • or, and
    Databases
    • Supported databases
    • Adding a database
    Reference
    • Cheat sheet
    • Errors
    Start here

    Getting started

    Install the core and a database package, serve a schema, curl it.

    Install

    Install the package for your database. It brings the core and the database driver with it, except for SQLite, which also needs better-sqlite3:

    npm install @crudy/restloom-postgres
    DatabasePackage
    PostgreSQL 13+@crudy/restloom-postgres
    MySQL 8.0+@crudy/restloom-mysql
    SQL Server 2022+@crudy/restloom-mssql
    SQLite 3.44+@crudy/restloom-sqlite

    Each of them exports the whole core, so everything is imported from that one package. The examples in these pages use @crudy/restloom-postgres; with another database, import from its package instead.

    Serve a schema

    import http from 'node:http';
    import { createREST, nodeListener, postgres } from '@crudy/restloom-postgres';
     
    const rest = createREST({
        db: postgres(process.env.DATABASE_URL),
        expose: { schemas: ['app'] },
    });
     
    http.createServer(nodeListener(rest, { prefix: '/api' })).listen(3000);

    nodeListener comes with the core, so no framework is needed. Every table and view of app is now a resource, read-only:

    curl -g 'http://localhost:3000/api/todos?select=id,name,owner(name)&status=eq.open'

    Add write: true beside expose to create, update and delete rows in every table too. Do it once your authorize hook decides who may write: Writes.

    Next

    • Discovery and overrides: what becomes a resource, which columns are hidden, how relations are named.
    • Query grammar: everything a GET can ask.
    • Writes and procedures: turning writes on, calling functions.
    • Security and hooks: authorising requests, row security, scoping.
    • Adapters: Fastify, Express, or any framework.
    Next What a table becomes
    restloom - a REST API generated from your database catalog
    DocumentationDownloadSource