mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-23 01:08:28 +02:00
Tweaks
This commit is contained in:
@@ -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:
|
If you prefer starting from scratch, manually install the types package:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
npm install @yaakapp/api
|
npm install -D @yaakapp/api
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@yaakapp/api",
|
"name": "@yaakapp/api",
|
||||||
"version": "0.6.4",
|
"version": "0.6.5",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"api-client",
|
"api-client",
|
||||||
"insomnia-alternative",
|
"insomnia-alternative",
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
use crate::connection_or_tx::ConnectionOrTx;
|
use crate::connection_or_tx::ConnectionOrTx;
|
||||||
use crate::error::Error::DBRowNotFound;
|
|
||||||
use crate::models::{AnyModel, UpsertModelInfo};
|
use crate::models::{AnyModel, UpsertModelInfo};
|
||||||
use crate::util::{ModelChangeEvent, ModelPayload, UpdateSource};
|
use crate::util::{ModelChangeEvent, ModelPayload, UpdateSource};
|
||||||
use log::error;
|
use log::error;
|
||||||
@@ -25,10 +24,13 @@ impl<'a> DbContext<'a> {
|
|||||||
where
|
where
|
||||||
M: Into<AnyModel> + Clone + UpsertModelInfo,
|
M: Into<AnyModel> + Clone + UpsertModelInfo,
|
||||||
{
|
{
|
||||||
match self.find_optional::<M>(col, value) {
|
let (sql, params) = Query::select()
|
||||||
Some(v) => Ok(v),
|
.from(M::table_name())
|
||||||
None => Err(DBRowNotFound(format!("{:?}", 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>(
|
pub(crate) fn find_optional<'s, M>(
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ pub enum Error {
|
|||||||
|
|
||||||
#[error("Model error: {0}")]
|
#[error("Model error: {0}")]
|
||||||
GenericError(String),
|
GenericError(String),
|
||||||
|
|
||||||
#[error("DB Migration Failed: {0}")]
|
#[error("DB Migration Failed: {0}")]
|
||||||
MigrationError(String),
|
MigrationError(String),
|
||||||
|
|
||||||
@@ -30,9 +30,6 @@ pub enum Error {
|
|||||||
#[error("Multiple base environments for {0}. Delete duplicates before continuing.")]
|
#[error("Multiple base environments for {0}. Delete duplicates before continuing.")]
|
||||||
MultipleBaseEnvironments(String),
|
MultipleBaseEnvironments(String),
|
||||||
|
|
||||||
#[error("Database row not found: {0}")]
|
|
||||||
DBRowNotFound(String),
|
|
||||||
|
|
||||||
#[error("unknown error")]
|
#[error("unknown error")]
|
||||||
Unknown,
|
Unknown,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ impl<'a> DbContext<'a> {
|
|||||||
return self.resolve_auth_for_folder(&folder);
|
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))
|
Ok(self.resolve_auth_for_workspace(&workspace))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user