mirror of
https://github.com/uqbar-dao/nectar.git
synced 2024-12-29 19:41:39 +03:00
sqlite: docstrings for blobs, remove backup
This commit is contained in:
parent
7626f8eb34
commit
e4d9bfef28
@ -381,18 +381,6 @@ async fn handle_request(
|
||||
tx.commit()?;
|
||||
(serde_json::to_vec(&SqliteResponse::Ok).unwrap(), None)
|
||||
}
|
||||
SqliteAction::Backup => {
|
||||
for db_ref in state.open_dbs.iter() {
|
||||
let db = db_ref.value().lock().await;
|
||||
let result: rusqlite::Result<()> = db
|
||||
.query_row("PRAGMA wal_checkpoint(TRUNCATE)", [], |_| Ok(()))
|
||||
.map(|_| ());
|
||||
if let Err(e) = result {
|
||||
return Err(SqliteError::RusqliteError(e.to_string()));
|
||||
}
|
||||
}
|
||||
(serde_json::to_vec(&SqliteResponse::Ok).unwrap(), None)
|
||||
}
|
||||
};
|
||||
|
||||
if let Some(target) = km.rsvp.or_else(|| expects_response.map(|_| source)) {
|
||||
@ -530,10 +518,6 @@ async fn check_caps(
|
||||
|
||||
Ok(())
|
||||
}
|
||||
SqliteAction::Backup => {
|
||||
// flushing WALs for backup
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,25 +13,59 @@ pub struct SqliteRequest {
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
pub enum SqliteAction {
|
||||
/// Opens an existing sqlite database or creates a new one if it doesn't exist.
|
||||
Open,
|
||||
/// Permanently deletes the entire sqlite database.
|
||||
RemoveDb,
|
||||
/// Executes a write statement (INSERT/UPDATE/DELETE)
|
||||
///
|
||||
/// * `statement` - SQL statement to execute
|
||||
/// * `tx_id` - Optional transaction ID
|
||||
/// * blob: Vec<SqlValue> - Parameters for the SQL statement, where SqlValue can be:
|
||||
/// - null
|
||||
/// - boolean
|
||||
/// - i64
|
||||
/// - f64
|
||||
/// - String
|
||||
/// - Vec<u8> (binary data)
|
||||
Write {
|
||||
statement: String,
|
||||
tx_id: Option<u64>,
|
||||
},
|
||||
/// Executes a read query (SELECT)
|
||||
///
|
||||
/// * blob: Vec<SqlValue> - Parameters for the SQL query, where SqlValue can be:
|
||||
/// - null
|
||||
/// - boolean
|
||||
/// - i64
|
||||
/// - f64
|
||||
/// - String
|
||||
/// - Vec<u8> (binary data)
|
||||
Query(String),
|
||||
/// Starts a new transaction
|
||||
BeginTx,
|
||||
Commit {
|
||||
tx_id: u64,
|
||||
},
|
||||
Backup,
|
||||
/// Commits transaction with given ID
|
||||
Commit { tx_id: u64 },
|
||||
}
|
||||
|
||||
/// Responses from SQLite operations
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
pub enum SqliteResponse {
|
||||
/// Operation succeeded
|
||||
Ok,
|
||||
/// Query returned results
|
||||
///
|
||||
/// * blob: Vec<Vec<SqlValue>> - Array of rows, where each row contains SqlValue types:
|
||||
/// - null
|
||||
/// - boolean
|
||||
/// - i64
|
||||
/// - f64
|
||||
/// - String
|
||||
/// - Vec<u8> (binary data)
|
||||
Read,
|
||||
/// Transaction started with ID
|
||||
BeginTx { tx_id: u64 },
|
||||
/// Operation failed
|
||||
Err(SqliteError),
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user