2025-03-23 01:19:17 +07:00
|
|
|
use anyhow::{bail, Result};
|
|
|
|
|
use surrealdb::sql::Thing;
|
|
|
|
|
|
|
|
|
|
pub fn get_id(thing: &Thing) -> Result<(&str, &str)> {
|
|
|
|
|
let table = thing.tb.as_str();
|
|
|
|
|
let id = match &thing.id {
|
|
|
|
|
surrealdb::sql::Id::String(s) => s.as_str(),
|
|
|
|
|
_ => bail!("Unsupported ID type"),
|
|
|
|
|
};
|
|
|
|
|
Ok((table, id))
|
|
|
|
|
}
|
2025-03-30 02:46:16 +07:00
|
|
|
|
|
|
|
|
pub fn extract_id(thing: &Thing) -> String {
|
|
|
|
|
let id = thing.id.to_raw();
|
|
|
|
|
id
|
|
|
|
|
}
|