FEAT Enabled chrono datetimes in the database.
This commit is contained in:
parent
884822a230
commit
2e08b02def
|
@ -12,11 +12,13 @@ readme = "./README.org"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
thiserror = "1.0.20"
|
thiserror = "1.0.20"
|
||||||
tokio = { version = "0.2.22", features = ["rt-threaded"] }
|
tokio = { version = "0.2.22", features = ["rt-threaded", "blocking"] }
|
||||||
serde = { version = "1.0.116", features = ["derive"] }
|
serde = { version = "1.0.116", features = ["derive"] }
|
||||||
serde_json = "1.0.56"
|
serde_json = "1.0.56"
|
||||||
|
chrono = { version = "0.4.18", features = ["serde"] }
|
||||||
sqlx = { version = "0.4.0-beta.1", default-features = false, features = [
|
sqlx = { version = "0.4.0-beta.1", default-features = false, features = [
|
||||||
"runtime-tokio",
|
"runtime-tokio",
|
||||||
|
"chrono",
|
||||||
"sqlite",
|
"sqlite",
|
||||||
"macros",
|
"macros",
|
||||||
] }
|
] }
|
||||||
|
|
|
@ -41,4 +41,21 @@ mod tests {
|
||||||
let unfoundnote = storagepool.fetch_note("nonexistent-note").await;
|
let unfoundnote = storagepool.fetch_note("nonexistent-note").await;
|
||||||
assert!(unfoundnote.is_err());
|
assert!(unfoundnote.is_err());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// #[tokio::test(threaded_scheduler)]
|
||||||
|
// async fn can_save_a_note() {
|
||||||
|
// let storagepool = fresh_inmemory_database().await;
|
||||||
|
// let note_id = storagepool.store_note("noteid", "notecontent", "note").await;
|
||||||
|
// assert!(note_id.is_ok());
|
||||||
|
// let note_id = note_id.unwrap();
|
||||||
|
// assert!(note_id > 0);
|
||||||
|
//
|
||||||
|
// let foundnote = storepool.fetch_note("noteid").await;
|
||||||
|
// assert!(foundnote.is_ok());
|
||||||
|
// let foundnote = foundnote.unwrap();
|
||||||
|
// assert_eq!(foundnote.content, "notecontent");
|
||||||
|
// assert_eq!(foundnote.notetype, "note");
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,11 @@ CREATE TABLE notes (
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
uuid TEXT NOT NULL UNIQUE,
|
uuid TEXT NOT NULL UNIQUE,
|
||||||
content TEXT NULL,
|
content TEXT NULL,
|
||||||
notetype TEXT
|
notetype TEXT,
|
||||||
|
creation_date DATETIME NOT NULL,
|
||||||
|
updated_date DATETIME NOT NULL,
|
||||||
|
lastview_date DATETIME NOT NULL,
|
||||||
|
deleted_date DATETIME NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE INDEX notes_uuids ON notes (uuid);
|
CREATE INDEX notes_uuids ON notes (uuid);
|
||||||
|
@ -18,6 +22,10 @@ CREATE TABLE pages (
|
||||||
title text NOT NULL UNIQUE,
|
title text NOT NULL UNIQUE,
|
||||||
slug text NOT NULL UNIQUE,
|
slug text NOT NULL UNIQUE,
|
||||||
note_id INTEGER,
|
note_id INTEGER,
|
||||||
|
creation_date DATETIME NOT NULL,
|
||||||
|
updated_date DATETIME NOT NULL,
|
||||||
|
lastview_date DATETIME NOT NULL,
|
||||||
|
deleted_date DATETIME NOT NULL,
|
||||||
FOREIGN KEY (note_id) REFERENCES notes (id) ON DELETE NO ACTION ON UPDATE NO ACTION
|
FOREIGN KEY (note_id) REFERENCES notes (id) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
use chrono::{DateTime, Utc};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use sqlx::{self, FromRow};
|
use sqlx::{self, FromRow};
|
||||||
|
|
||||||
|
@ -7,6 +8,10 @@ pub struct RawPage {
|
||||||
slug: String,
|
slug: String,
|
||||||
title: String,
|
title: String,
|
||||||
note_id: i64,
|
note_id: i64,
|
||||||
|
creation_date: DateTime<Utc>,
|
||||||
|
updated_date: DateTime<Utc>,
|
||||||
|
lastview_date: DateTime<Utc>,
|
||||||
|
deleted_date: DateTime<Utc>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Serialize, Deserialize, Debug, FromRow)]
|
#[derive(Clone, Serialize, Deserialize, Debug, FromRow)]
|
||||||
|
@ -15,4 +20,8 @@ pub struct RawNote {
|
||||||
uuid: String,
|
uuid: String,
|
||||||
content: String,
|
content: String,
|
||||||
notetype: String,
|
notetype: String,
|
||||||
|
creation_date: DateTime<Utc>,
|
||||||
|
updated_date: DateTime<Utc>,
|
||||||
|
lastview_date: DateTime<Utc>,
|
||||||
|
deleted_date: DateTime<Utc>,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue