feat: make ref_date optional
This commit is contained in:
@@ -6,7 +6,7 @@ pub fn run(path: &path::Path) {
|
|||||||
CREATE TABLE IF NOT EXISTS entity (
|
CREATE TABLE IF NOT EXISTS entity (
|
||||||
id TEXT PRIMARY KEY,
|
id TEXT PRIMARY KEY,
|
||||||
class TEXT NOT NULL,
|
class TEXT NOT NULL,
|
||||||
ref_date INTEGER NOT NULL
|
ref_date INTEGER
|
||||||
);
|
);
|
||||||
CREATE TABLE IF NOT EXISTS attribute (
|
CREATE TABLE IF NOT EXISTS attribute (
|
||||||
id TEXT,
|
id TEXT,
|
||||||
|
|||||||
@@ -3,11 +3,14 @@ use crate::*;
|
|||||||
pub fn run(row: &rusqlite::Row) -> rusqlite::Result<Entity> {
|
pub fn run(row: &rusqlite::Row) -> rusqlite::Result<Entity> {
|
||||||
let id: String = row.get(0)?;
|
let id: String = row.get(0)?;
|
||||||
let class: String = row.get(1)?;
|
let class: String = row.get(1)?;
|
||||||
let ref_date: u64 = row.get(2)?;
|
let ref_date: Option<u64> = row.get(2)?;
|
||||||
Ok(Entity::default()
|
let entity = Entity {
|
||||||
.with_id(&id)
|
id,
|
||||||
.with_class(&class)
|
class,
|
||||||
.with_ref_date(ref_date))
|
ref_date,
|
||||||
|
..Entity::default()
|
||||||
|
};
|
||||||
|
Ok(entity)
|
||||||
}
|
}
|
||||||
|
|
||||||
// #[cfg(test)]
|
// #[cfg(test)]
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use crate::*;
|
|||||||
pub struct O {
|
pub struct O {
|
||||||
pub id: String,
|
pub id: String,
|
||||||
pub state: EntityState,
|
pub state: EntityState,
|
||||||
pub ref_date: u64,
|
pub ref_date: Option<u64>,
|
||||||
pub class: String,
|
pub class: String,
|
||||||
pub attributes: std::collections::HashMap<String, Attribute>,
|
pub attributes: std::collections::HashMap<String, Attribute>,
|
||||||
}
|
}
|
||||||
@@ -28,7 +28,7 @@ impl O {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
pub fn with_ref_date(mut self, ref_date: u64) -> Self {
|
pub fn with_ref_date(mut self, ref_date: u64) -> Self {
|
||||||
self.ref_date = ref_date;
|
self.ref_date = Some(ref_date);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
pub fn with_attribute(mut self, id: &str, value: impl Into<Value>) -> Self {
|
pub fn with_attribute(mut self, id: &str, value: impl Into<Value>) -> Self {
|
||||||
|
|||||||
Reference in New Issue
Block a user