Skip to main content

Crate type_bridge_orm

Crate type_bridge_orm 

Source
Expand description

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

This crate provides:

§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);

Re-exports§

pub use attribute::TypeBridgeAttribute;
pub use attribute::ValueType;
pub use descriptor::EntityDescriptor;
pub use descriptor::OwnedAttributeDescriptor;
pub use descriptor::RelationDescriptor;
pub use descriptor::RoleDescriptor;
pub use descriptor::TypeDescriptor;
pub use descriptor::TypeDescriptorRef;
pub use dynamic::DynamicAggregate;
pub use dynamic::DynamicAttributeMap;
pub use dynamic::DynamicComparisonOp;
pub use dynamic::DynamicEntityRow;
pub use dynamic::DynamicExpr;
pub use dynamic::DynamicRelationRow;
pub use dynamic::DynamicRolePlayer;
pub use dynamic::DynamicRolePlayerInput;
pub use dynamic::DynamicSort;
pub use entity::Annotation;
pub use entity::OwnedAttributeInfo;
pub use entity::TypeBridgeEntity;
pub use error::OrmError;
pub use error::Result;
pub use expr::Agg;
pub use expr::AggResult;
pub use expr::Expr;
pub use expr::GroupByResult;
pub use expr::SortDir;
pub use field_ref::FieldRef;
pub use field_ref::RolePlayerFieldRef;
pub use field_ref::RoleRef;
pub use filter::Filter;
pub use hooks::CrudOperation;
pub use hooks::HookContext;
pub use hooks::HookError;
pub use hooks::HookRunner;
pub use hooks::LifecycleHook;
pub use hooks::PreHookResult;
pub use hooks::TypeKind;
pub use manager::DynamicEntityManager;
pub use manager::DynamicRelationManager;
pub use manager::EntityManager;
pub use manager::RelationManager;
pub use query::EntityQuery;
pub use query::GroupByEntityQuery;
pub use query::GroupByRelationQuery;
pub use query::RelationQuery;
pub use registry::DescriptorRegistry;
pub use relation::RoleInfo;
pub use relation::RolePlayerRef;
pub use relation::TypeBridgeRelation;
pub use schema::SchemaDiff;
pub use schema::SchemaInfo;
pub use schema::SchemaManager;
pub use session::ensure_database_exists;
pub use session::Database;
pub use session::Transaction;
pub use session::TransactionContext;
pub use session::TxType;
pub use value::AttributeValue;

Modules§

attribute
TypeDB attribute type trait and convenience macro.
codegen
Code generator: TypeQL schema → Rust source files.
descriptor
Owned runtime descriptors for dynamic ORM access.
dynamic
Dynamic rows and inputs used by runtime descriptor managers.
entity
TypeDB entity trait with default AST generation methods.
error
Unified error types for the ORM crate.
expr
Expression system for building typed queries.
field_ref
Type-safe field references for building query expressions.
filter
Query filters for entity lookups.
hooks
Lifecycle hook system for CRUD operations.
manager
Entity and relation managers with supporting modules.
query
Chainable query builders for entities and relations.
registry
Explicit runtime descriptor registry.
relation
TypeDB relation trait with default AST generation methods.
schema
Schema management: registration, generation, diffing, and synchronization.
session
Session layer for TypeDB connectivity.
value
Typed attribute values corresponding to TypeDB value types.

Macros§

define_attribute
Define a TypeDB attribute type with a single line.

Structs§

ConnectOptions
Connection-time options for the version-gated TypeDB runtime.

Functions§

embedded_driver_versions
Return the driver versions compiled into this build, keyed by protocol band.