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§
- Dependency
Node - A node in a dependency tree, representing a table linked via
record<>fields. - Event
Def - A parsed event definition.
- Field
Def - A parsed field definition.
- Function
Def - A parsed function definition.
- Index
Def - A parsed index definition.
- Param
Def - A parsed param definition.
- Schema
Graph - A semantic graph of SurrealQL schema definitions.
- Source
Location - Source location of a definition in a
.surqlfile. - Table
Def - A parsed table definition.