Can now save and delete archive content. This includes the hosted file. It still needs some work though. The content delete should also remove the hosted file.

This commit is contained in:
Scott Idem
2024-11-08 11:25:19 -05:00
parent b93cacdfcc
commit abcd5c54c2
7 changed files with 170 additions and 189 deletions

View File

@@ -6,6 +6,9 @@ import { db_archives } from "$lib/db_archives";
let ae_promises: key_val = {};
// TESTING NOTE: I changed these to all use async and await. Not sure if this helps or hurts things. Mainly this is related to the Dexie DB changes. 2024-11-08
// Updated 2024-09-25
export async function load_ae_obj_id__archive_content(
{
@@ -135,12 +138,14 @@ export async function create_ae_obj__archive_content(
archive_id,
data_kv,
params={},
try_cache = true,
log_lvl=0
}: {
api_cfg: any,
archive_id: string,
data_kv: key_val,
params?: key_val,
try_cache?: boolean,
log_lvl?: number
}
) {
@@ -160,11 +165,13 @@ export async function create_ae_obj__archive_content(
})
.then(async function (archive_content_obj_create_result) {
if (archive_content_obj_create_result) {
await db_save_ae_obj_li__archive_content(
{
obj_type: 'archive_content',
obj_li: [archive_content_obj_create_result]
});
if (try_cache) {
await db_save_ae_obj_li__archive_content(
{
obj_type: 'archive_content',
obj_li: [archive_content_obj_create_result]
});
}
return archive_content_obj_create_result;
} else {
return null;
@@ -183,6 +190,59 @@ export async function create_ae_obj__archive_content(
}
// Updated 2024-11-08
export async function delete_ae_obj_id__archive_content(
{
api_cfg,
archive_content_id,
method = 'delete', // 'delete', 'disable', 'hide'
params = {},
try_cache = true,
log_lvl = 0
}: {
api_cfg: any,
archive_content_id: string,
method?: string,
params?: key_val,
try_cache?: boolean,
log_lvl?: number
}
) {
if (log_lvl) {
console.log(`*** delete_ae_obj_id__archive_content() *** archive_content_id=${archive_content_id}`);
}
ae_promises.delete__archive_content_obj = await api.delete_ae_obj_id_crud({
api_cfg: api_cfg,
obj_type: 'archive_content',
obj_id: archive_content_id,
key: api_cfg.api_crud_super_key,
params: params,
method: method,
log_lvl: log_lvl
})
.then(function (archive_content_obj_delete_result) {
// if (archive_content_obj_delete_result) {
// return archive_content_obj_delete_result;
// } else {
// return null;
// }
})
.catch(function (error) {
console.log('No results returned or failed.', error);
})
.finally(function () {
db_archives.content.delete(archive_content_id); // Delete from the DB no matter what.
});
if (log_lvl) {
console.log('ae_promises.delete__archive_content_obj:', ae_promises.delete__archive_content_obj);
}
return ae_promises.delete__archive_content_obj;
}
// Updated 2024-09-25
export async function update_ae_obj__archive_content(
{

View File

@@ -14,6 +14,7 @@ import {
load_ae_obj_id__archive_content,
load_ae_obj_li__archive_content,
create_ae_obj__archive_content,
delete_ae_obj_id__archive_content,
update_ae_obj__archive_content,
// qry__archive_content,
db_save_ae_obj_li__archive_content,
@@ -30,6 +31,7 @@ let export_obj = {
load_ae_obj_id__archive_content: load_ae_obj_id__archive_content,
load_ae_obj_li__archive_content: load_ae_obj_li__archive_content,
create_ae_obj__archive_content: create_ae_obj__archive_content,
delete_ae_obj_id__archive_content: delete_ae_obj_id__archive_content,
update_ae_obj__archive_content: update_ae_obj__archive_content,
db_save_ae_obj_li__archive_content: db_save_ae_obj_li__archive_content,
};

View File

@@ -215,7 +215,7 @@ export async function delete_ae_obj_id__event_presenter(
ae_promises.delete__event_presenter_obj = await api.delete_ae_obj_id_crud({
api_cfg: api_cfg,
obj_type: 'event_presenter',
obj_id: event_presenter_id, // NOTE: This is the FQDN, not normally the ID.
obj_id: event_presenter_id,
key: api_cfg.api_crud_super_key,
params: params,
method: method,