mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 20:38:52 +00:00
fix(electron): export and import (#9767)
This commit is contained in:
@@ -25,6 +25,12 @@ pub struct UpdateRow {
|
||||
pub doc_id: Option<String>,
|
||||
}
|
||||
|
||||
#[napi(object)]
|
||||
pub struct DocTimestampRow {
|
||||
pub doc_id: Option<String>,
|
||||
pub timestamp: NaiveDateTime,
|
||||
}
|
||||
|
||||
#[napi(object)]
|
||||
pub struct InsertRow {
|
||||
pub doc_id: Option<String>,
|
||||
@@ -146,6 +152,20 @@ impl SqliteConnection {
|
||||
Ok(updates)
|
||||
}
|
||||
|
||||
#[napi]
|
||||
pub async fn get_doc_timestamps(&self) -> napi::Result<Vec<DocTimestampRow>> {
|
||||
// get the greatest timestamp of each doc_id
|
||||
let updates = sqlx::query_as!(
|
||||
DocTimestampRow,
|
||||
"SELECT doc_id, MAX(timestamp) as timestamp FROM updates GROUP BY doc_id"
|
||||
)
|
||||
.fetch_all(&self.pool)
|
||||
.await
|
||||
.map_err(anyhow::Error::from)?;
|
||||
|
||||
Ok(updates)
|
||||
}
|
||||
|
||||
#[napi]
|
||||
pub async fn delete_updates(&self, doc_id: Option<String>) -> napi::Result<()> {
|
||||
match doc_id {
|
||||
|
||||
Reference in New Issue
Block a user