type-bridge-orm 1.5.1

Async ORM for TypeDB built on type-bridge-core-lib
Documentation

Async ORM for TypeDB built on type-bridge-core-lib.

This crate provides:

  • [TypeBridgeEntity] trait for mapping Rust structs to TypeDB entity types
  • [TypeBridgeRelation] trait for mapping Rust structs to TypeDB relation types
  • [TypeBridgeAttribute] trait and [define_attribute!] macro for attribute types
  • [EntityManager] / [RelationManager] for typed CRUD operations
  • [DescriptorRegistry] plus dynamic managers for runtime schemas
  • [Database] + [Transaction] + [TransactionContext] session layer
  • [Filter] for equality-based queries

Quick start

use type_bridge_orm::{
    define_attribute, Database, EntityManager, Filter,
    TypeBridgeEntity, OwnedAttributeInfo, AttributeValue,
};

// Define attribute types
define_attribute!(Name, "name", "string");
define_attribute!(Age, "age", "long");

// Define entity (manual impl; derive macros in a later phase)
struct Person { iid: Option<String>, name: Name, age: Age }
// impl TypeBridgeEntity for Person { ... }

// CRUD operations
let db = Database::connect("localhost:1729", "mydb", "admin", "password").await?;
let manager = EntityManager::<Person>::new(&db);
manager.insert(&mut person).await?;
let people = manager.all().await?;

Runtime descriptors

Runtime descriptors are the shared Rust substrate for generated schemas and language bindings. They are registered without a database and then used to construct dynamic managers:

use type_bridge_orm::{
    DescriptorRegistry, DynamicEntityManager, EntityDescriptor,
    OwnedAttributeDescriptor, ValueType,
};

let registry = DescriptorRegistry::new();
let person = registry.register_entity(EntityDescriptor {
    type_name: "person".into(),
    is_abstract: false,
    parent_type: None,
    owned_attributes: vec![OwnedAttributeDescriptor {
        field_name: "name".into(),
        attr_name: "name".into(),
        value_type: ValueType::String,
        annotations: vec![],
        is_optional: false,
        is_ordered: false,
    }],
})?;

let manager = DynamicEntityManager::new(&db, person);