Primitives.org.ai

ai-database

Your data, flowing like conversation

npm install ai-database

Chain operations. Batch relationships. Ask questions.

import { DB } from 'ai-database'

const { db } = DB({
  Lead: { name: 'string', company: 'Company.leads' },
  Company: { name: 'string' }
})

// Chain without await
const leads = db.Lead.list()
const qualified = await leads.filter(l => l.score > 80)

// Batch relationship loading
const enriched = await leads.map(lead => ({
  name: lead.name,
  company: lead.company,  // Batch loaded!
}))

Promise Pipelining

Chain without await:

const leads = db.Lead.list()
const topLeads = leads.filter(l => l.score > 80)
const names = topLeads.map(l => l.name)

// Only await when you need it
const result = await names

Batch Loading

Eliminate N+1 queries:

const enriched = await db.Lead.list().map(lead => ({
  lead,
  company: lead.company,  // ONE query for all
}))

Natural Language

const results = await db.Lead`who closed deals this month?`
Was this page helpful?

On this page