Skip to main content

Module schema_graph

Module schema_graph 

Source
Expand description

Schema graph — semantic model built from SurrealQL definitions.

Provides a queryable graph of tables, fields, indexes, functions, and their relationships. Built from parsed .surql files.

§Example

use surql_parser::SchemaGraph;

let schema = SchemaGraph::from_source("
    DEFINE TABLE user SCHEMAFULL;
    DEFINE FIELD name ON user TYPE string;
    DEFINE FIELD age ON user TYPE int;
    DEFINE INDEX email_idx ON user FIELDS email UNIQUE;
    DEFINE FUNCTION fn::greet($name: string) -> string { RETURN 'Hello, ' + $name; };
").unwrap();

assert_eq!(schema.table_names().count(), 1);
assert_eq!(schema.fields_of("user").len(), 2);
assert_eq!(schema.indexes_of("user").len(), 1);
assert!(schema.function("greet").is_some());

Structs§

DependencyNode
A node in a dependency tree, representing a table linked via record<> fields.
EventDef
A parsed event definition.
FieldDef
A parsed field definition.
FunctionDef
A parsed function definition.
IndexDef
A parsed index definition.
ParamDef
A parsed param definition.
SchemaGraph
A semantic graph of SurrealQL schema definitions.
SourceLocation
Source location of a definition in a .surql file.
TableDef
A parsed table definition.