Database

PostgreSQL, supercharged

Every indxBASE project ships a dedicated Postgres 16 cluster with PostGIS, pgvector, pgcrypto and pg_cron pre-installed.

Create a table

001_init.sql
create table public.posts (
  id          uuid primary key default gen_random_uuid(),
  author_id   uuid not null references auth.users(id) on delete cascade,
  title       text not null,
  body        text,
  published   boolean not null default false,
  created_at  timestamptz not null default now()
);

grant select, insert, update, delete on public.posts to authenticated;
alter table public.posts enable row level security;

create policy "Authors manage own posts"
  on public.posts for all to authenticated
  using (author_id = auth.uid())
  with check (author_id = auth.uid());

Relationships

typescript
// Embed related rows with the resource path syntax
const { data } = await nb
  .from("posts")
  .select("id, title, author:users(id, email), tags(name)")
  .eq("published", true);

Queries

typescript
await nb.from("posts")
  .select("id, title, created_at")
  .gte("created_at", "2026-01-01")
  .ilike("title", "%launch%")
  .order("created_at", { ascending: false })
  .range(0, 19);

Insert / Update / Delete

typescript
await nb.from("posts").insert({ title: "Hello" });
await nb.from("posts").update({ published: true }).eq("id", id);
await nb.from("posts").delete().eq("id", id);
await nb.from("posts").upsert({ id, title: "Edited" });

Indexes

sql
create index posts_created_at_idx on public.posts (created_at desc);
create index posts_title_trgm    on public.posts using gin (title gin_trgm_ops);
create index posts_embedding_idx on public.posts using hnsw (embedding vector_cosine_ops);

Database Functions

sql
create or replace function public.publish_post(_id uuid)
returns public.posts
language sql security definer set search_path = public as $$
  update public.posts set published = true where id = _id returning *;
$$;