This commit is contained in:
Gregory Schier
2025-07-02 07:47:36 -07:00
parent fa62f88fa4
commit ff26cc1344
5 changed files with 11 additions and 12 deletions

View File

@@ -24,5 +24,5 @@ the [Quick Start Guide](https://feedback.yaak.app/help/articles/6911763-plugins-
If you prefer starting from scratch, manually install the types package:
```shell
npm install @yaakapp/api
npm install -D @yaakapp/api
```

View File

@@ -1,6 +1,6 @@
{
"name": "@yaakapp/api",
"version": "0.6.4",
"version": "0.6.5",
"keywords": [
"api-client",
"insomnia-alternative",

View File

@@ -1,5 +1,4 @@
use crate::connection_or_tx::ConnectionOrTx;
use crate::error::Error::DBRowNotFound;
use crate::models::{AnyModel, UpsertModelInfo};
use crate::util::{ModelChangeEvent, ModelPayload, UpdateSource};
use log::error;
@@ -25,10 +24,13 @@ impl<'a> DbContext<'a> {
where
M: Into<AnyModel> + Clone + UpsertModelInfo,
{
match self.find_optional::<M>(col, value) {
Some(v) => Ok(v),
None => Err(DBRowNotFound(format!("{:?}", M::table_name()))),
}
let (sql, params) = Query::select()
.from(M::table_name())
.column(Asterisk)
.cond_where(Expr::col(col).eq(value))
.build_rusqlite(SqliteQueryBuilder);
let mut stmt = self.conn.prepare(sql.as_str()).expect("Failed to prepare query");
Ok(stmt.query_row(&*params.as_params(), M::from_row)?)
}
pub(crate) fn find_optional<'s, M>(

View File

@@ -20,7 +20,7 @@ pub enum Error {
#[error("Model error: {0}")]
GenericError(String),
#[error("DB Migration Failed: {0}")]
MigrationError(String),
@@ -30,9 +30,6 @@ pub enum Error {
#[error("Multiple base environments for {0}. Delete duplicates before continuing.")]
MultipleBaseEnvironments(String),
#[error("Database row not found: {0}")]
DBRowNotFound(String),
#[error("unknown error")]
Unknown,
}

View File

@@ -64,7 +64,7 @@ impl<'a> DbContext<'a> {
return self.resolve_auth_for_folder(&folder);
}
let workspace = self.get_workspace(&http_request.workspace_id)?;
let workspace = self.get_workspace("invalid")?;
Ok(self.resolve_auth_for_workspace(&workspace))
}