dittolive-ditto 3.0.9

Ditto is a peer to peer cross-platform database that allows mobile, web, IoT and server apps to sync with or without an internet connection.
Documentation
#[allow(deprecated)]
mod deprecated {
    use_prelude!();
    use serde_json::json;

    use crate::{
        store::collection::document::DittoDocument as _, test_helpers::setup_ditto,
        types::rga::DittoRga,
    };

    #[test]
    fn accessing_in_a_document() {
        let ditto = setup_ditto().unwrap();
        let store = ditto.store();
        let collection = store.collection("test").unwrap();

        let rga_content = vec![json!(1u8), json!("string"), json!(["b", "c"])];
        let rga = DittoRga::from(rga_content.clone());
        let doc_id = collection.upsert(json!({ "a": rga })).unwrap();

        let doc = collection.find_by_id(&doc_id).exec().unwrap();
        let rga: DittoRga = doc.get("a").unwrap();
        assert_eq!(rga.value, rga_content);
    }

    #[test]
    fn accessing_in_a_mut_document() {
        let ditto = setup_ditto().unwrap();
        let store = ditto.store();
        let collection = store.collection("test").unwrap();

        let rga_content = vec![json!(1u8), json!("string"), json!(["b", "c"])];
        let rga = DittoRga::from(rga_content.clone());
        let doc_id = collection.upsert(json!({ "a": rga })).unwrap();

        collection
            .find_by_id(&doc_id)
            .update(|mut_doc| {
                let mut_doc = mut_doc.unwrap();

                let rga: DittoRga = mut_doc.get("a").unwrap();
                assert_eq!(rga.value, rga_content);
            })
            .unwrap();
    }
}