import Dexie, { type Table } from 'dexie'; import type { key_val } from '$lib/stores/ae_stores'; // li = list // kv = key value list // Updated 2024-11-13 export interface Post { id: string; // id_random: string; post_id: string; // post_id_random: string; account_id: string; // account_id_random: string; person_id?: null | string; external_person_id?: null | string; // For IDAA this is the Novi UUID user_id?: null | string; topic_id?: string; topic?: string; // or topic_name? topic_name?: string; name: null | string; title: null | string; // summary?: null|string; content?: null | string; anonymous?: null | boolean; full_name?: null | string; email?: null | string; notify?: null | boolean; enable_comments?: null | boolean; archive?: null | boolean; archive_on?: null | Date; linked_li_json?: null | string; cfg_json?: null | key_val; 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; // Generated fields for sorting locally only tmp_sort_1?: null | string; tmp_sort_2?: null | string; // Additional fields for convenience (database views) post_comment_count?: number; // Placeholder for generated temp data hosted_file_id_li?: null | Array; hosted_file_obj_li?: null | Array; upload_complete?: boolean; } // Updated 2024-11-13 export interface Post_Comment { id: string; // id_random: string; post_comment_id: string; // post_comment_id_random: string; post_id: string; // post_id_random: string; external_person_id?: null | string; // For IDAA this is the Novi UUID name: null | string; title: null | string; // summary?: null|string; content?: null | string; anonymous?: null | boolean; full_name?: null | string; email?: null | string; notify?: null | boolean; linked_li_json?: null | string; cfg_json?: null | key_val; 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; // Generated fields for sorting locally only tmp_sort_1?: null | string; tmp_sort_2?: null | string; // Additional fields for convenience (database views) } // Updated 2024-09-25 export class MySubClassedDexie extends Dexie { // We just tell the typing system this is the case post!: Table; comment!: Table; constructor() { super('ae_posts_db'); this.version(1).stores({ post: ` id, post_id, account_id, topic_id, topic, name, title, full_name, email, archive, archive_on, tmp_sort_1, tmp_sort_2, enable, hide, priority, sort, group, notes, created_on, updated_on, [updated_on+created_on], [created_on+updated_on]`, comment: ` id, post_comment_id, post_id, name, title, full_name, email, tmp_sort_1, tmp_sort_2, enable, hide, priority, sort, group, notes, created_on, updated_on, [updated_on+created_on]` }); } } export const db_posts = new MySubClassedDexie();