semilattice-database

Example

```rust use versatiledata::prelude::*; use semilatticedatabase::{ Database ,TransactionRecord ,CollectionRow };

let dir="D:/sl-test/";

if std::path::Path::new(dir).exists(){ std::fs::removedirall(dir).unwrap(); std::fs::createdirall(dir).unwrap(); }else{ std::fs::createdirall(dir).unwrap(); } let mut database=Database::new(dir);

let collectionperson=database.collectionid("person"); let collectionhistory=database.collectionid("history");

let mut t=database.begintransaction(); t.update(&mut vec![ TransactionRecord::new( collectionperson ,Update::New ,Activity::Active ,0 ,0 ,vec![ ("name","Joe".tostring()) ,("birthday","1972-08-02".tostring()) ] ,vec![("history",vec![ TransactionRecord::new( collectionhistory ,Update::New ,Activity::Active ,0 ,0 ,vec![ ("date","1972-08-02".tostring()) ,("event","Birth".tostring()) ] ,vec![] ) ,TransactionRecord::new( collectionhistory ,Update::New ,Activity::Active ,0 ,0 ,vec![ ("date","1999-12-31".tostring()) ,("event","Mariage".tostring()) ] ,vec![] ) ])] ) ,TransactionRecord::new( collectionperson ,Update::New ,Activity::Active ,0 ,0 ,vec![ ("name","Tom".tostring()) ,("birthday","2000-12-12".tostring()) ] ,vec![("history",vec![ TransactionRecord::new( collectionhistory ,Update::New ,Activity::Active ,0 ,0 ,vec![ ("date","2000-12-12".tostring()) ,("event","Birth".tostring()) ] ,vec![] ) ])] ) ,TransactionRecord::new( collectionperson ,Update::New ,Activity::Active ,0 ,0 ,vec![ ("name","Billy".tostring()) ,("birthday","1982-03-03".to_string()) ] ,vec![] ) ]); t.commit();

let relation=database.relation(); if let Some(p)=database.data(collectionperson){ for i in 1..=3{ println!( "{},{}" ,p.fieldstr(i,"name") ,p.fieldstr(i,"birthday") ); for h in relation.childs("history",&CollectionRow::new(collectionperson,i)){ if let Some(col)=database.data(h.collectionid()){ let row=h.row(); println!( " {} : {}" ,col.fieldstr(row,"date") ,col.field_str(row,"event") );

        }
    }
}

}