In the admin dashboard, go to Schema → Tables and click Create Table.
2
Define the Schema
Create a table with the following columns:
CREATE TABLE posts ( id BLOB PRIMARY KEY DEFAULT (uuid_v7()) NOT NULL, created INTEGER DEFAULT (unixepoch()) NOT NULL, updated INTEGER DEFAULT (unixepoch()) NOT NULL, title TEXT NOT NULL, content TEXT NOT NULL, author_id BLOB REFERENCES _user(id), published INTEGER DEFAULT 0 NOT NULL) STRICT;
# Register a new usercurl -X POST http://localhost:4000/api/auth/v1/register \ -H "Content-Type: application/json" \ -d '{"email":"[email protected]","password":"secretpassword"}'# Login to get a tokencurl -X POST http://localhost:4000/api/auth/v1/login \ -H "Content-Type: application/json" \ -d '{"email":"[email protected]","password":"secretpassword"}'
Then create a post using the auth token:
curl -X POST http://localhost:4000/api/records/v1/posts \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_TOKEN_HERE" \ -d '{ "title": "My First Post", "content": "Hello from TrailBase!", "published": 1 }'
# Get a specific postcurl http://localhost:4000/api/records/v1/posts/POST_ID_HERE# Filter published postscurl "http://localhost:4000/api/records/v1/posts?published[eq]=1"# Search by titlecurl "http://localhost:4000/api/records/v1/posts?title[like]=%First%"