Initial work on finally creating and implementing more generic and standardized CRUD functions for my Aether objects. It should work very well for Delete, Create, and Update. Load and Load List will need more work.

This commit is contained in:
Scott Idem
2025-08-01 17:30:30 -04:00
parent 9ed4bd85e1
commit 0a4940161d
6 changed files with 722 additions and 47 deletions

View File

@@ -104,35 +104,35 @@ export async function load_ae_obj_id__journal(
}
if (inc_entry_li) {
// Load the entries for the journal
if (log_lvl) {
console.log(`Need to load the entry list for the journal now`);
}
let load_journal_entry_obj_li = load_ae_obj_li__journal_entry({
api_cfg: api_cfg,
for_obj_type: 'journal',
for_obj_id: journal_id,
enabled: enabled, // all, disabled, enabled
hidden: hidden, // all, hidden, not_hidden
limit: limit, // Limit for the entries
offset: offset,
order_by_li: order_by_li,
params: params,
try_cache: try_cache,
log_lvl: log_lvl
})
.then((journal_entry_obj_li) => {
if (log_lvl) {
console.log(`journal_entry_obj_li = `, journal_entry_obj_li);
}
return journal_entry_obj_li;
});
if (log_lvl) {
console.log(`journal_entry_obj_li = `, load_journal_entry_obj_li);
}
ae_promises.load__journal_obj.journal_entry_li = load_journal_entry_obj_li;
// Load the entries for the journal
if (log_lvl) {
console.log(`Need to load the entry list for the journal now`);
}
let load_journal_entry_obj_li = load_ae_obj_li__journal_entry({
api_cfg: api_cfg,
for_obj_type: 'journal',
for_obj_id: journal_id,
enabled: enabled, // all, disabled, enabled
hidden: hidden, // all, hidden, not_hidden
limit: limit, // Limit for the entries
offset: offset,
order_by_li: order_by_li,
params: params,
try_cache: try_cache,
log_lvl: log_lvl
})
.then((journal_entry_obj_li) => {
if (log_lvl) {
console.log(`journal_entry_obj_li = `, journal_entry_obj_li);
}
return journal_entry_obj_li;
});
if (log_lvl) {
console.log(`journal_entry_obj_li = `, load_journal_entry_obj_li);
}
ae_promises.load__journal_obj.journal_entry_li = load_journal_entry_obj_li;
}
return ae_promises.load__journal_obj;
}

View File

@@ -150,6 +150,104 @@ export interface Journal {
obj_updated_on?: null|Date;
}
export const journal_field_li = [
'id',
'journal_id',
'snapshot_id',
'previous_id',
'next_id',
'external_id',
'import_id',
'code',
'for_type',
'for_id',
'type_code',
'account_id',
'person_id',
'name',
'short_name',
'summary',
'outline',
'description',
'description_md_html',
'description_md_html_alt',
'description_html',
'description_json',
'start_datetime',
'end_datetime',
'timezone',
'alert',
'alert_msg',
'sort_by',
'sort_by_desc',
'cfg_json',
'data_json',
'ux_mode',
'passcode_read',
'passcode_read_expire',
'passcode_write',
'passcode_write_expire',
'passcode_timeout',
'private_passcode',
'auth_key',
'enable',
'hide',
'archive', // Archive the journal
'archive_on', // Archive date
'priority', // Priority flag
'sort', // Sort order
'group', // Group name
'notes', // Notes about the journal
'created_on', // Creation date
'updated_on', // Last updated date
'tmp_sort_1', // Temporary sort field 1
'tmp_sort_2', // Temporary sort field 2
'tmp_sort_3', // Temporary sort field 3
'combined_passcode', // For Journal Entry encryption password
'file_count', // Only files directly under a journal
'journal_file_id_li_json', // JSON string of file IDs
'person__given_name', // Person's given name
'person__family_name', // Person's family name
'person__full_name', // Person's full name
'person__primary_email', // Person's primary email
'person__passcode', // Person's passcode
'person__kv_json', // JSON formatted key value pairs for multiple people
'journal_name', // Journal name
'journal_location_code', // Journal location code
'journal_location_name', // Journal location name
'journal_entry_count', // Count of journal entries
'journal_entry_kv', // Key value list of the entries
'journal_entry_li', // List of journal entries
'journal_file_kv', // Key value list of the files
'journal_file_li', // List of journal files
'obj_id', // Object ID
'obj_ext_uid', // External UID
'obj_ext_id', // External ID
'obj_import_id', // Import ID
'obj_code', // Object code
'obj_account_id', // Object account ID
'obj_passcode', // Object passcode
'obj_type', // Object type
'obj_type_ver_id', // Object type version ID
'obj_name', // Object name
'obj_summary', // Object summary
'obj_outline', // Object outline
'obj_description', // Object description
'obj_enable', // Object enable flag
'obj_enable_on', // Object enable date
'obj_archive_on', // Object archive date
'obj_hide', // Object hide flag
'obj_priority', // Object priority
'obj_sort', // Object sort order
'obj_group', // Object group name
'obj_cfg_json', // Object configuration JSON
'obj_notes', // Object notes
'obj_created_on', // Object creation date
'obj_updated_on' // Object last updated date
];
// Updated 2025-04-02
export interface Journal_Entry {
@@ -301,6 +399,111 @@ export interface Journal_Entry {
obj_updated_on?: null|Date;
}
export const journal_entry_field_li = [
'id',
'journal_entry_id',
'journal_id',
'code',
'for_type',
'for_id',
'template',
'activity_code',
'category_code',
'topic_code',
'type_code',
'tags',
'journal_entry_type',
'account_id',
'person_id',
'public',
'private',
'personal',
'professional',
'name',
'short_name',
'summary',
'outline',
'content',
'content_md_html',
'content_md_html_alt',
'content_html',
'content_json',
'content_encrypted',
'history',
'history_encrypted',
'passcode_hash',
'start_datetime',
'end_datetime',
'timezone',
'seconds',
'location',
'latitude',
'longitude',
'billable',
'bill_to',
'bill_rate',
'billable_minutes',
'alert',
'alert_msg',
'parent_id',
'related_entry_id_li',
'data_json',
'passcode_read',
'passcode_read_expire',
'passcode_write',
'passcode_write_expire',
'enable',
'hide',
'priority',
'sort',
'group',
'notes',
'created_on',
'updated_on',
'tmp_sort_1',
'tmp_sort_2',
'tmp_sort_3',
'file_count',
'journal_file_id_li_json',
'journal_code',
'journal_name',
'person__given_name',
'person__family_name',
'person__full_name',
'person__primary_email',
'person__passcode',
'person__kv_json',
'journal_file_kv',
'journal_file_li',
'obj_id',
'obj_ext_uid',
'obj_ext_id',
'obj_import_id',
'obj_code',
'obj_account_id',
'obj_passcode',
'obj_type',
'obj_type_ver_id',
'obj_name',
'obj_summary',
'obj_outline',
'obj_description',
'obj_enable',
'obj_enable_on',
'obj_archive_on',
'obj_hide',
'obj_priority',
'obj_sort',
'obj_group',
'obj_cfg_json',
'obj_notes',
'obj_created_on',
'obj_updated_on'
];
// Updated 2024-06-10
export class MySubClassedDexie extends Dexie {
@@ -310,7 +513,7 @@ export class MySubClassedDexie extends Dexie {
constructor() {
super('ae_journals_db');
this.version(3).stores({
this.version(4).stores({
journal: `
id, journal_id,
code,
@@ -321,7 +524,7 @@ export class MySubClassedDexie extends Dexie {
start_datetime, end_datetime,
timezone,
tmp_sort_1, tmp_sort_2, tmp_sort_3,
enable, hide, priority, sort, group, notes, created_on, updated_on`,
enable, hide, priority, sort, group, created_on, updated_on`,
journal_entry: `
id, journal_entry_id,
journal_id,
@@ -332,7 +535,7 @@ export class MySubClassedDexie extends Dexie {
start_datetime, end_datetime,
timezone,
tmp_sort_1, tmp_sort_2, tmp_sort_3,
enable, hide, priority, sort, group, notes, created_on, updated_on`,
enable, hide, priority, sort, group, created_on, updated_on`,
});
}
}