Data Layer

The site-scoped client (client.site(siteId)) exposes lower-level data operations for content collections, row-level data, file assets, and custom actions.

const site = client.site(siteId)

Collections

Content collections are named groups of structured rows, created and schematized in the BusinessDash dashboard.

const collections = await site.collections.list()
// → [{ id, name, slug, fieldSchema }, ...]

const collection = await site.collections.get('gallery')
// → { id, name, slug, fieldSchema, rowCount }

const created = await site.collections.create({
  name: 'Testimonials',
  slug: 'testimonials',
  fieldSchema: { fields: [{ key: 'quote', type: 'text' }] },
})

Rows

Read and write individual rows within a collection.

// List rows
const rows = await site.rows.list('testimonials', { limit: 20, offset: 0 })

// Upsert a row (create or update by id)
const row = await site.rows.upsert('testimonials', {
  id: 'row-1',
  data: { quote: 'Amazing service!' },
})

// Query rows with filters
const results = await site.rows.query('testimonials', {
  filters: [{ field: 'rating', op: 'gte', value: 4 }],
})

Assets

Upload files to BusinessDash's media library from your site.

const asset = await site.assets.create({
  file: formData.get('file') as File,
  folder: 'uploads',
  tags: ['public'],
})
// → { id, url, thumbnailUrl, size, mime }

Actions

Trigger custom actions defined in your BusinessDash dashboard (webhooks, automations).

const result = await site.actions.run('send-welcome-email', {
  to: 'jane@example.com',
  name: 'Jane',
})