@brickbed/schema
v0.0.1
Published
Schema definition helpers for Brickbed - the document database built for distributed edge apps
Downloads
92
Maintainers
Readme
@brickbed/schema
Schema definition helpers for Brickbed - the document database built for distributed edge apps.
Coming Soon
This package is under active development. Join the waitlist at brickbed.com to be notified when it's ready.
What is Brickbed?
Brickbed is a document database that stores data in object storage with local NVMe caching for fast reads.
- Multi-region - Deploy close to your users
- Low latency reads - Millisecond response times
- Schema-first - TypeScript types and validation
- Simple API - REST endpoints with typed SDK
Installation
npm install @brickbed/schema
# or
bun add @brickbed/schemaUsage
import { defineSchema, defineCollection, v } from '@brickbed/schema';
export default defineSchema({
posts: defineCollection({
title: v.string(),
slug: v.string(),
content: v.string(),
status: v.union(v.literal('draft'), v.literal('published')),
publishedAt: v.optional(v.number()),
tags: v.array(v.string()),
})
.index('by_slug', ['slug'])
.index('by_status', ['status', 'publishedAt']),
authors: defineCollection({
name: v.string(),
email: v.string(),
bio: v.optional(v.string()),
}),
});Validators
v.string()- String valuesv.number()- Number valuesv.boolean()- Boolean valuesv.array(validator)- Arraysv.object(shape)- Nested objectsv.optional(validator)- Optional fieldsv.union(a, b, ...)- Union typesv.literal(value)- Literal valuesv.id(collection)- Reference to another collection
Links
License
MIT
