init
Some checks failed
ci/woodpecker/push/test Pipeline failed

This commit is contained in:
JMARyA 2025-04-28 18:53:21 +02:00
commit 6c54873ca2
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
34 changed files with 5502 additions and 0 deletions

29
examples/parent.rs Normal file
View file

@ -0,0 +1,29 @@
use owl::{db::model::person::Person, prelude::*};
#[relation("parent", Person, "child", Person, RelationKind::Unidirectional)]
pub struct ParentRelation;
pub fn main() {
let db = Database::in_memory();
let p = Person::new_id("myperson", "first", "last");
db.save(p);
let p: Model<Person> = db.get("myperson").unwrap();
let p2 = Person::new_id("secperson", "second", "last");
let p2 = db.save(p2);
ParentRelation.add(&p, &p2, None, &db);
let children_of = ParentRelation::get_child_of(&p, &db);
dbg!(&children_of);
let children_of = dereference(&children_of, &db);
children_of
.iter()
.for_each(|x| println!("child: {:?}", x.read()));
let my_parents = dereference(&ParentRelation::get_parent_of(&p2, &db), &db);
my_parents
.iter()
.for_each(|x| println!("parent: {:?}", x.read()));
}