Skip to content
~/docs/guides/schema
DOCUMENTATION

Schema Definition

Define type-safe node and edge schemas

KiteDB schemas define the structure of your graph data. This guide covers how to define nodes, edges, and properties.

Defining Nodes

Nodes are the vertices in your graph. Each node type needs a unique name and can have typed properties.

schema.ts
import { kite } from '@kitedb/core';

const db = await kite('./blog.kitedb', {
  nodes: [
    {
      name: 'article',
      props: {
        title: { type: 'string' },
        content: { type: 'string' },
        published: { type: 'bool' },
        views: { type: 'int' },
        rating: { type: 'float' },
      },
    },
  ],
  edges: [],
});

Property Types

KiteDB supports the following property types:

  • string – Text strings
  • int – 64-bit integers
  • float – 64-bit floating point numbers
  • bool – Boolean values
  • vector – Float32 embedding vectors

TypeScript builders are available as top-level exports (e.g. string()) or under prop (e.g. prop.string()).

Defining Edges

Edges connect nodes and can have their own properties.

typescript
const db = await kite('./blog.kitedb', {
  nodes: [
    { name: 'user', props: { name: { type: 'string' } } },
    { name: 'article', props: { title: { type: 'string' } } },
  ],
  edges: [
    {
      name: 'authored',
      props: {
        role: { type: 'string' },  // 'author' | 'contributor'
      },
    },
    {
      name: 'likes',
      props: {
        likedAt: { type: 'int' },  // Unix timestamp
      },
    },
  ],
});

Next Steps