Creating standardized functions. Mainly for create and delete.
This commit is contained in:
@@ -341,16 +341,20 @@ export async function create_ae_obj__event(
|
||||
account_id,
|
||||
data_kv,
|
||||
params={},
|
||||
log_lvl=0
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
account_id: string,
|
||||
data_kv: key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** create_ae_obj__event() *** account_id=${account_id}`);
|
||||
if (log_lvl) {
|
||||
console.log(`*** create_ae_obj__event() *** account_id=${account_id}`);
|
||||
}
|
||||
|
||||
ae_promises.create__event = await api.create_ae_obj_crud({
|
||||
api_cfg: api_cfg,
|
||||
@@ -366,11 +370,13 @@ export async function create_ae_obj__event(
|
||||
})
|
||||
.then(function (event_obj_create_result) {
|
||||
if (event_obj_create_result) {
|
||||
db_save_ae_obj_li__event(
|
||||
{
|
||||
obj_type: 'event',
|
||||
obj_li: [event_obj_create_result]
|
||||
});
|
||||
if (try_cache) {
|
||||
db_save_ae_obj_li__event(
|
||||
{
|
||||
obj_type: 'event',
|
||||
obj_li: [event_obj_create_result]
|
||||
});
|
||||
}
|
||||
return event_obj_create_result;
|
||||
} else {
|
||||
return null;
|
||||
@@ -389,6 +395,57 @@ export async function create_ae_obj__event(
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-11-08
|
||||
export async function delete_ae_obj_id__event(
|
||||
{
|
||||
api_cfg,
|
||||
event_id,
|
||||
method = 'delete', // 'delete', 'disable', 'hide'
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
event_id: string,
|
||||
method?: string,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** delete_ae_obj_id__event() *** event_id=${event_id}`);
|
||||
}
|
||||
|
||||
ae_promises.delete__event_obj = await api.delete_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event',
|
||||
obj_id: event_id,
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
method: method,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.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_id=${event_id}`);
|
||||
}
|
||||
db_events.events.delete(event_id); // Delete from the DB no matter what.
|
||||
}
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.delete__event_obj:', ae_promises.delete__event_obj);
|
||||
}
|
||||
|
||||
return ae_promises.delete__event_obj;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-09-25
|
||||
export async function update_ae_obj__event(
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user