fix(native): return type casts (#7986)

This commit is contained in:
darkskygit
2024-08-27 05:53:05 +00:00
parent 6557b5d4b6
commit 10a066a52a
2 changed files with 6 additions and 8 deletions

View File

@@ -336,7 +336,7 @@ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
nativeBinding = require('./affine.wasi.cjs')
} catch (err) {
if (process.env.NAPI_RS_FORCE_WASI) {
console.error(err)
loadErrors.push(err)
}
}
if (!nativeBinding) {
@@ -344,7 +344,7 @@ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
nativeBinding = require('@affine/native-wasm32-wasi')
} catch (err) {
if (process.env.NAPI_RS_FORCE_WASI) {
console.error(err)
loadErrors.push(err)
}
}
}

View File

@@ -166,7 +166,7 @@ impl SqliteConnection {
}
#[napi]
pub async fn get_updates_count(&self, doc_id: Option<String>) -> napi::Result<i32> {
pub async fn get_updates_count(&self, doc_id: Option<String>) -> napi::Result<i64> {
let count = match doc_id {
Some(doc_id) => {
sqlx::query!(
@@ -185,9 +185,7 @@ impl SqliteConnection {
.map_err(anyhow::Error::from)?
.count
}
}
.try_into()
.unwrap();
};
Ok(count)
}
@@ -396,14 +394,14 @@ impl SqliteConnection {
}
#[napi]
pub async fn get_max_version(&self) -> napi::Result<i32> {
pub async fn get_max_version(&self) -> napi::Result<i64> {
// 4 is the current version
let version = sqlx::query!("SELECT COALESCE(MAX(version), 4) AS max_version FROM version_info")
.fetch_one(&self.pool)
.await
.map_err(anyhow::Error::from)?
.max_version;
Ok(version.try_into().unwrap())
Ok(version)
}
#[napi]