Rust mock-store is a simple Rust in-memory mock-store for testing and prototyping (with modql implementation).

Do not use this in production code.

mock-store uses modql for filtering capability. It's also a great way to experiment with modql.

Example | Library Scope | Limitations

Example

See examples/readme.rs for the full working source.

```rs // -- Store is Send + Sync (backed by Arc/Mutex). let store = Store::new();

// -- Insert the objects. store.insert(Ticket { id: 1, title: "Ticket AAA".tostring(), })?; store.insert(Ticket { id: 1, title: "Ticket BBB".tostring(), })?;

// -- List all tickets (no filter). let alltickets = store.list::(None)?; // [Ticket { id: 1, title: "Ticket AAA" }, Ticket { id: 1, title: "Ticket BBB" }] println!("{:<20}: {alltickets:?}", "all tickets");

// -- List with filter (using modql: https://github.com/jeremychone/rust-modql) let filter: FilterGroup = vec![("title", OpValString::Contains("AA".tostring())).into()].into(); let doubleatickets = store.list::(filter)?; // [Ticket { id: 1, title: "Ticket AAA" }] println!("{:<20}: {doubleatickets:?}", "doublea_tickets");

// -- Update with filter. let filter: FilterGroup = vec![("title", OpValString::Contains("BB".tostring())).into()].into(); let count = store.update::(filter, |mut ticket| { ticket.title = "TICKET BB - UPDATE".tostring(); ticket })?; // 1 println!("{:<20}: {count:?}", "tickets updated");

// -- List all tickets again. let alltickets = store.list::(None)?; // [Ticket { id: 1, title: "Ticket AAA" }, Ticket { id: 1, title: "TICKET BB - UPDATE" }] println!("{:<20}: {alltickets:?}", "all tickets");

// -- Delete is: store.delete::(filter)?;

```

Library Scope

Current Limitations