Crud for locations.

This commit is contained in:
xPolar 2022-06-13 22:11:02 -07:00
parent 56fa6def8f
commit 9ce9a0e0aa

View file

@ -1,5 +1,5 @@
use crate::{
file::cas::FileIdentifierJob, library::get_library_path, node::NodeState,
file::cas::FileIdentifierJob, library::get_library_path, node::NodeState, prisma::location,
util::db::create_connection,
};
use job::{Job, JobReport, Jobs};
@ -252,8 +252,26 @@ impl Node {
// ctx.queue_job(Box::new(FileIdentifierJob));
CoreResponse::LocCreate(loc)
}
ClientCommand::LocUpdate { id: _, name: _ } => todo!(),
ClientCommand::LocDelete { id: _ } => todo!(),
ClientCommand::LocUpdate { id, name } => {
ctx.database
.location()
.find_unique(location::id::equals(id))
.update(vec![location::name::set(name)])
.exec()
.await?;
CoreResponse::Success(())
}
ClientCommand::LocDelete { id } => {
ctx.database
.location()
.find_unique(location::id::equals(id))
.delete()
.exec()
.await?;
CoreResponse::Success(())
}
// CRUD for files
ClientCommand::FileRead { id: _ } => todo!(),
// ClientCommand::FileEncrypt { id: _, algorithm: _ } => todo!(),