feat: create package

This commit is contained in:
Ahmet Kaan GÜMÜŞ 2024-11-20 00:16:31 +03:00
parent 0dacf1f54f
commit 5bdc82a3a0
2 changed files with 16 additions and 3 deletions

View file

@ -6,6 +6,8 @@ use surrealdb::{
};
use tokio::time::sleep;
use crate::package::Package;
static DB: LazyLock<Surreal<Client>> = LazyLock::new(Surreal::init);
pub async fn establish_connection() -> Result<(), surrealdb::Error> {
@ -21,3 +23,10 @@ pub async fn is_alive() -> bool {
_ = sleep(Duration::from_secs(1)) => false
}
}
pub async fn create_package(package: Package) -> Option<Package> {
DB.create::<Option<Package>>(package.get_name())
.content(package)
.await
.unwrap()
}