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:
Scott Idem
2024-09-25 19:09:28 -04:00
parent 702da83ce5
commit 0f40629bfe
5 changed files with 278 additions and 133 deletions

View File

@@ -265,6 +265,117 @@ export async function load_ae_obj_li__event_location(
}
// Updated 2024-06-25
export async function create_ae_obj__event_location(
{
api_cfg,
event_id,
data_kv,
params={},
log_lvl=0
}: {
api_cfg: any,
event_id: string,
data_kv: key_val,
params?: key_val,
log_lvl?: number
}
) {
console.log(`*** create_ae_obj__event_location() *** event_id=${event_id}`);
ae_promises.create__event_location = await api.create_ae_obj_crud({
api_cfg: api_cfg,
obj_type: 'event_location',
fields: {
event_id_random: event_id,
...data_kv
},
key: api_cfg.api_crud_super_key,
params: params,
return_obj: true,
log_lvl: log_lvl
})
.then(function (event_location_obj_create_result) {
if (event_location_obj_create_result) {
db_save_ae_obj_li__event_location(
{
obj_type: 'event_location',
obj_li: [event_location_obj_create_result]
});
return event_location_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_location:', ae_promises.create__event_location);
}
return ae_promises.create__event_location;
}
// Updated 2024-09-25
export async function update_ae_obj__event_location(
{
api_cfg,
event_location_id,
data_kv,
params = {},
try_cache = true,
log_lvl = 0
}: {
api_cfg: any,
event_location_id: string,
data_kv: key_val,
params?: key_val,
try_cache?: boolean,
log_lvl?: number
}
) {
if (log_lvl) {
console.log(`*** update_ae_obj__event_location() *** event_location_id=${event_location_id}`, data_kv);
}
ae_promises.update__event_location_obj = await api.update_ae_obj_id_crud({
api_cfg: api_cfg,
obj_type: 'event_location',
obj_id: event_location_id,
fields: data_kv,
key: api_cfg.api_crud_super_key,
params: params,
return_obj: true,
log_lvl: log_lvl
})
.then(function (event_location_obj_update_result) {
if (event_location_obj_update_result) {
if (try_cache) {
db_save_ae_obj_li__event_location({
obj_type: 'event_location', obj_li: [event_location_obj_update_result]
});
}
return event_location_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_location_obj:', ae_promises.update__event_location_obj);
}
return ae_promises.update__event_location_obj;
}
export async function search__event_location(
{
api_cfg,
@@ -385,117 +496,6 @@ export async function search__event_location(
}
// Updated 2024-06-25
export async function create_ae_obj__event_location(
{
api_cfg,
event_id,
data_kv,
params={},
log_lvl=0
}: {
api_cfg: any,
event_id: string,
data_kv: key_val,
params?: key_val,
log_lvl?: number
}
) {
console.log(`*** create_ae_obj__event_location() *** event_id=${event_id}`);
ae_promises.create__event_location = await api.create_ae_obj_crud({
api_cfg: api_cfg,
obj_type: 'event_location',
fields: {
event_id_random: event_id,
...data_kv
},
key: api_cfg.api_crud_super_key,
params: params,
return_obj: true,
log_lvl: log_lvl
})
.then(function (event_location_obj_create_result) {
if (event_location_obj_create_result) {
db_save_ae_obj_li__event_location(
{
obj_type: 'event_location',
obj_li: [event_location_obj_create_result]
});
return event_location_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_location:', ae_promises.create__event_location);
}
return ae_promises.create__event_location;
}
// Updated 2024-09-25
export async function update_ae_obj__event_location(
{
api_cfg,
event_location_id,
data_kv,
params = {},
try_cache = true,
log_lvl = 0
}: {
api_cfg: any,
event_location_id: string,
data_kv: key_val,
params?: key_val,
try_cache?: boolean,
log_lvl?: number
}
) {
if (log_lvl) {
console.log(`*** update_ae_obj__event_location() *** event_location_id=${event_location_id}`, data_kv);
}
ae_promises.update__event_location_obj = await api.update_ae_obj_id_crud({
api_cfg: api_cfg,
obj_type: 'event_location',
obj_id: event_location_id,
fields: data_kv,
key: api_cfg.api_crud_super_key,
params: params,
return_obj: true,
log_lvl: log_lvl
})
.then(function (event_location_obj_update_result) {
if (event_location_obj_update_result) {
if (try_cache) {
db_save_ae_obj_li__event_location({
obj_type: 'event_location', obj_li: [event_location_obj_update_result]
});
}
return event_location_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_location_obj:', ae_promises.update__event_location_obj);
}
return ae_promises.update__event_location_obj;
}
// This function will loop through the event_location_obj_li and save each one to the DB.
// Updated 2024-06-25
export function db_save_ae_obj_li__event_location(