Skip to content

Guides

Schema definition

Define type-safe node and edge schemas

A schema declares the node and edge types in your graph and the typed properties each type carries. This guide covers nodes, edges, and the available property types.

Defining nodes

Nodes are the vertices of the graph. Each node type needs a unique name and can declare 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 two nodes. Like nodes, they can carry 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