Skip to main content

Crate ravenrs_app_sqlite

Crate ravenrs_app_sqlite 

Source
Expand description

Records in SQLite, as an ObjectSpace.

use std::rc::Rc;

use ravenrs_app::{EntityInfo, FieldInfo, FieldKind, ObjectSpace, Query, Value};
use ravenrs_app_sqlite::{SqliteDatabase, TableMap};

let account = EntityInfo::new("Account")
    .field(FieldInfo::new("id", FieldKind::Integer).key())
    .field(FieldInfo::new("name", FieldKind::Text));
let connection = Rc::new(rusqlite::Connection::open_in_memory()?);
let database = SqliteDatabase::builder(connection).managed(account, TableMap::new("accounts"))?.build();

let mut space = database.space();
let mut object = space.new_object("Account")?;
object.set("name", "Corrente");
space.save(object)?;
space.commit()?;
let found = database.space().query("Account", &Query::all())?;
assert_eq!(found[0].get("name"), Value::Text("Corrente".into()));

Structs§

SqlWords
What to say when the database refuses something, where {0} is the field’s caption.
SqliteAttachmentStore
Keeps the content of attached files in the database, in a table apart from the records.
SqliteBuilder
Puts a database together, one entity at a time.
SqliteDatabase
Records in SQLite, on a connection that can be shared with the rest of an application. Any number of spaces share it.
SqliteModelStore
Keeps a layer of the model in the database, under a name, as for one person’s settings.
SqliteObjectSpace
A unit of work over a SqliteDatabase. A commit is one transaction.
TableMap
How an entity lands on a table.

Functions§

entities_from_schema
Entities from the tables a database already has, for an application over a database that came first: a field per column, a reference per foreign key, and a required field per column that asks for it. A table with no single key is left out, since a record could not be found. What comes out is a start: captions and rules are for the application to give.