95 lines
2.5 KiB
TypeScript
95 lines
2.5 KiB
TypeScript
import Dexie, { type Table } from 'dexie';
|
|
|
|
// li = list
|
|
// kv = key value list
|
|
|
|
// Updated 2024-07-17
|
|
export interface Person {
|
|
id: string;
|
|
// id_random: string;
|
|
person_id: string;
|
|
person_id_random: string;
|
|
|
|
external_id?: string; // This may be semi-random or unique only withing the account.
|
|
external_sys_id?: string; // Generated by an external system. Ideally this should be something like a UUID. It may be the same as the external_id if nothing given.
|
|
code?: string;
|
|
|
|
account_id?: string; // Technically this is not required for global users.
|
|
account_id_random?: string; // Technically this is not required for global users.
|
|
|
|
person_profile_id?: null|string;
|
|
person_profile_id_random?: null|string; // The new table person_profile will be used soon...
|
|
|
|
user_id?: string;
|
|
user_id_random?: string;
|
|
|
|
pronouns?: null|string;
|
|
informal_name?: null|string;
|
|
title_names?: null|string;
|
|
given_name: string;
|
|
middle_name?: null|string;
|
|
family_name: null|string;
|
|
designations?: null|string;
|
|
|
|
professional_title?: null|string;
|
|
|
|
full_name?: string;
|
|
|
|
affiliations?: null|string;
|
|
|
|
primary_email?: string;
|
|
|
|
biography?: null|string;
|
|
|
|
agree?: null|boolean;
|
|
comments?: null|string;
|
|
|
|
passcode?: null|string;
|
|
|
|
data_json?: null|string;
|
|
|
|
enable: null|boolean;
|
|
hide?: null|boolean;
|
|
priority?: null|boolean
|
|
sort?: null|number;
|
|
group?: null|string;
|
|
notes?: null|string;
|
|
created_on: Date;
|
|
updated_on?: null|Date;
|
|
|
|
// Additional fields for convenience (database views)
|
|
username?: string;
|
|
user_name?: null|string;
|
|
user_email?: null|string;
|
|
user_allow_auth_key?: null|boolean; // For sign in without password
|
|
user_super?: boolean;
|
|
user_manager?: boolean;
|
|
user_administrator?: boolean;
|
|
user_public?: boolean;
|
|
}
|
|
|
|
|
|
// Updated 2024-06-24
|
|
export class MySubClassedDexie extends Dexie {
|
|
person!: Table<Person>;
|
|
// user!: Table<User>;
|
|
|
|
constructor() {
|
|
super('ae_core_db');
|
|
this.version(1).stores({
|
|
person: `
|
|
id, person_id, person_id_random,
|
|
external_id, code,
|
|
account_id, user_id,
|
|
account_id_random, user_id_random,
|
|
person_profile_id,
|
|
person_profile_id_random,
|
|
given_name, family_name,
|
|
full_name, affiliations, email,
|
|
agree,
|
|
enable, hide, priority, sort, group, created_on, updated_on`,
|
|
});
|
|
}
|
|
}
|
|
|
|
export const db_core = new MySubClassedDexie(); |