Skip to main content

Documentation Index

Fetch the complete documentation index at: https://ahvn.top/llms.txt

Use this file to discover all available pages before exploring further.

Entities are reusable logical schemas — independent of where data lives.

Field types

import heavenbase as hb

class Product(hb.Entity):
    name:        hb.ShortText    # max 255 chars
    description: hb.MediumText   # max 4095 chars
    price:       hb.Float        # float
    tags:        hb.Array        # list of strings
    metadata:    hb.Json         # arbitrary JSON
    in_stock:    hb.Boolean      # True/False
Every entity has an implicit id: Identifier (max 63 chars). Supply it at write time or HeavenBase generates a deterministic hash.
p = Product(id="p1", name="Widget", price=9.99)
print(p.to_dict())
# {'id': 'p1', 'name': 'Widget', 'price': 9.99}

Field routing

Route a field to a specific backend:
class Article(hb.Entity):
    title:  hb.ShortText = hb.field(hb.ShortText).route(to="main")
    body:   hb.MediumText = hb.field(hb.MediumText).route(to="main")
    vector: hb.Vector = hb.field(hb.Vector).route(to="vec")
The workspace’s router dispatches each field to its target backend automatically.

Computed fields

class User(hb.Entity):
    first: hb.ShortText
    last:  hb.ShortText
    full:  hb.ShortText = hb.field(hb.ShortText).compute(
        lambda first, last: f"{first} {last}",
        inputs=["first", "last"]
    )
Computed fields are not stored — they are evaluated at read time. The function receives each input field value as a positional argument.

JSON definition

Entities can also be defined from a dict:
Product = hb.entity_from_dict({
    "name": "Product",
    "fields": {
        "name":  "ShortText",
        "price": "Float",
        "tags":  "Array",
    }
})

Further Exploration

Related resources:
  • Entities — full entity reference
  • Routing — field-level backend dispatch
  • Schema — schema inspection and migration