mod common; use test_log::test; use microrm::prelude::*; #[derive(Entity)] struct Object { written: String, } #[derive(Entity)] struct Subject { written: String, } #[derive(Entity)] struct Verb { written: String, } #[derive(Default, Schema)] struct DictionarySchema { objects: microrm::IDMap, subjects: microrm::IDMap, verbs: microrm::IDMap, } #[derive(Entity)] struct Sentence { object: ObjectID, subject: SubjectID, verb: VerbID, } #[derive(Default, Schema)] struct SentenceSchema { sentences: microrm::IDMap, } #[derive(Default, Schema)] struct CombinedSchema { dictionary: DictionarySchema, sentence: SentenceSchema, } #[test] fn nested() { let (pool, db): (_, CombinedSchema) = common::open_test_db!(); let mut lease = pool.acquire().unwrap(); let obj_id = db .dictionary .objects .insert( &mut lease, Object { written: String::from("an_object"), }, ) .expect("couldn't insert object"); let subj_id = db .dictionary .subjects .insert( &mut lease, Subject { written: String::from("a_subject"), }, ) .expect("couldn't insert subject"); let verb_id = db .dictionary .verbs .insert( &mut lease, Verb { written: String::from("verb1"), }, ) .expect("couldn't insert verb"); db.sentence .sentences .insert( &mut lease, Sentence { object: obj_id, subject: subj_id, verb: verb_id, }, ) .expect("couldn't insert sentence"); }