Done with clean up for the night. Still need to rename all of the shared functions that start with handle_.
This commit is contained in:
@@ -6,16 +6,26 @@ import { db_events } from "$lib/db_events";
|
||||
let ae_promises: key_val = {};
|
||||
|
||||
|
||||
// Updated 2024-07-02
|
||||
// Updated 2024-09-25
|
||||
export async function handle_load_ae_obj_id__event(
|
||||
{
|
||||
api_cfg,
|
||||
event_id,
|
||||
inc_file_li = false,
|
||||
inc_location_li = false,
|
||||
inc_presentation_li = false,
|
||||
inc_presenter_li = false,
|
||||
inc_session_li = false,
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
event_id: string,
|
||||
inc_file_li?: boolean,
|
||||
inc_location_li?: boolean,
|
||||
inc_presentation_li?: boolean,
|
||||
inc_presenter_li?: boolean,
|
||||
inc_session_li?: boolean,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
@@ -62,12 +72,24 @@ export async function handle_load_ae_obj_li__event(
|
||||
{
|
||||
api_cfg,
|
||||
account_id,
|
||||
params={},
|
||||
try_cache=true,
|
||||
log_lvl=0
|
||||
inc_file_li = false,
|
||||
inc_location_li = false,
|
||||
inc_presentation_li = false,
|
||||
inc_presenter_li = false,
|
||||
inc_session_li = false,
|
||||
order_by_li = {'start_datetime': 'DESC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'},
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
account_id: string,
|
||||
inc_file_li?: boolean,
|
||||
inc_location_li?: boolean,
|
||||
inc_presentation_li?: boolean,
|
||||
inc_presenter_li?: boolean,
|
||||
inc_session_li?: boolean,
|
||||
order_by_li?: key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
@@ -94,7 +116,7 @@ export async function handle_load_ae_obj_li__event(
|
||||
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
order_by_li: {'start_datetime': 'DESC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'},
|
||||
order_by_li: order_by_li,
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
params_json: params_json,
|
||||
@@ -122,6 +144,118 @@ export async function handle_load_ae_obj_li__event(
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-09-25
|
||||
export async function create_ae_obj__event(
|
||||
{
|
||||
api_cfg,
|
||||
account_id,
|
||||
data_kv,
|
||||
params={},
|
||||
log_lvl=0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
account_id: string,
|
||||
data_kv: key_val,
|
||||
params?: key_val,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** create_ae_obj__event() *** account_id=${account_id}`);
|
||||
|
||||
ae_promises.create__event = await api.create_ae_obj_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event',
|
||||
fields: {
|
||||
account_id_random: account_id,
|
||||
...data_kv
|
||||
},
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (event_obj_create_result) {
|
||||
if (event_obj_create_result) {
|
||||
handle_db_save_ae_obj_li__event(
|
||||
{
|
||||
obj_type: 'event',
|
||||
obj_li: [event_obj_create_result]
|
||||
});
|
||||
return event_obj_create_result;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.create__event:', ae_promises.create__event);
|
||||
}
|
||||
return ae_promises.create__event;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-09-25
|
||||
export async function update_ae_obj__event(
|
||||
{
|
||||
api_cfg,
|
||||
event_id,
|
||||
data_kv,
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
event_id: string,
|
||||
data_kv: key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** update_ae_obj__event() *** event_id=${event_id}`, data_kv);
|
||||
}
|
||||
// ae_promises.update__event_obj = 'test';
|
||||
ae_promises.update__event_obj = await api.update_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event',
|
||||
obj_id: event_id,
|
||||
fields: data_kv,
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (event_obj_update_result) {
|
||||
if (event_obj_update_result) {
|
||||
if (try_cache) {
|
||||
handle_db_save_ae_obj_li__event({
|
||||
obj_type: 'event', obj_li: [event_obj_update_result]
|
||||
});
|
||||
}
|
||||
return event_obj_update_result;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.update__event_obj:', ae_promises.update__event_obj);
|
||||
}
|
||||
return ae_promises.update__event_obj;
|
||||
}
|
||||
|
||||
|
||||
// This function will loop through the event_obj_li and save each one to the DB.
|
||||
export function handle_db_save_ae_obj_li__event(
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user