Creating standardized functions. Mainly for create and delete.
This commit is contained in:
@@ -261,6 +261,7 @@ export async function create_ae_obj__event_presentation(
|
||||
event_session_id,
|
||||
data_kv,
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
@@ -268,10 +269,13 @@ export async function create_ae_obj__event_presentation(
|
||||
event_session_id: string,
|
||||
data_kv: key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** create_ae_obj__event_presentation() *** event_id=${event_id} event_session_id=${event_session_id}`);
|
||||
if (log_lvl) {
|
||||
console.log(`*** create_ae_obj__event_presentation() *** event_id=${event_id} event_session_id=${event_session_id}`);
|
||||
}
|
||||
|
||||
ae_promises.create__event_presentation = await api.create_ae_obj_crud({
|
||||
api_cfg: api_cfg,
|
||||
@@ -288,11 +292,13 @@ export async function create_ae_obj__event_presentation(
|
||||
})
|
||||
.then(function (event_presentation_obj_create_result) {
|
||||
if (event_presentation_obj_create_result) {
|
||||
db_save_ae_obj_li__event_presentation(
|
||||
{
|
||||
obj_type: 'event_presentation',
|
||||
obj_li: [event_presentation_obj_create_result]
|
||||
});
|
||||
if (try_cache) {
|
||||
db_save_ae_obj_li__event_presentation(
|
||||
{
|
||||
obj_type: 'event_presentation',
|
||||
obj_li: [event_presentation_obj_create_result]
|
||||
});
|
||||
}
|
||||
return event_presentation_obj_create_result;
|
||||
} else {
|
||||
return null;
|
||||
@@ -311,6 +317,65 @@ export async function create_ae_obj__event_presentation(
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-11-08
|
||||
export async function delete_ae_obj_id__event_presentation(
|
||||
{
|
||||
api_cfg,
|
||||
event_presentation_id,
|
||||
method = 'delete', // 'delete', 'disable', 'hide'
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
event_presentation_id: string,
|
||||
method?: string,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** delete_ae_obj_id__event_presentation() *** event_presentation_id=${event_presentation_id}`);
|
||||
}
|
||||
|
||||
ae_promises.delete__event_presentation_obj = await api.delete_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_presentation',
|
||||
obj_id: event_presentation_id,
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
method: method,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (event_presentation_obj_delete_result) {
|
||||
// if (event_presentation_obj_delete_result) {
|
||||
// // db_save_ae_obj_li__event_presentation({obj_type: 'event_presentation', obj_li: [event_presentation_obj_delete_result]});
|
||||
// return event_presentation_obj_delete_result;
|
||||
// } else {
|
||||
// return null;
|
||||
// }
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
if (try_cache) {
|
||||
if (log_lvl) {
|
||||
console.log(`Attempting to remove IDB entry for event_presentation_id=${event_presentation_id}`);
|
||||
}
|
||||
db_events.presentations.delete(event_presentation_id);
|
||||
}
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.delete__event_presentation_obj:', ae_promises.delete__event_presentation_obj);
|
||||
}
|
||||
|
||||
return ae_promises.delete__event_presentation_obj;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-09-25
|
||||
export async function update_ae_obj__event_presentation(
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user