fix(electron): export and import (#9767)

This commit is contained in:
forehalo
2025-01-20 08:48:03 +00:00
parent 2e18ae59e3
commit cb53baca89
26 changed files with 332 additions and 453 deletions

View File

@@ -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 {