reference

SDK Query Builder

Fluent chainable query builder for reading and writing data with postbasejs.

Published: March 22, 2026Updated: March 22, 2026

SDK Query Builder

The postbase.from(table) method returns a QueryBuilder<T> with a fully chainable, type-safe API.

Select

const { data, error } = await postbase
  .from('posts')
  .select('id, title, created_at')
  .eq('published', true)
  .order('created_at', { ascending: false })
  .limit(10)

Insert

const { data, error } = await postbase
  .from('posts')
  .insert({ title: 'Hello World', published: false })
  .returning('*')

Update

const { error } = await postbase
  .from('posts')
  .update({ published: true })
  .eq('id', postId)

Delete

const { error } = await postbase
  .from('posts')
  .delete()
  .eq('id', postId)

Upsert

const { data, error } = await postbase
  .from('profiles')
  .upsert({ id: userId, bio: 'Updated bio' }, { onConflict: 'id' })

Single Row

const { data: post } = await postbase
  .from('posts')
  .select('*')
  .eq('id', 1)
  .single()

Count

const { count } = await postbase
  .from('posts')
  .select('*', { count: 'exact', head: true })
  .eq('published', true)