Adding in the Archives and Posts DB and functions to get ready for IDAA changes.
This commit is contained in:
115
src/lib/db_posts.ts
Normal file
115
src/lib/db_posts.ts
Normal file
@@ -0,0 +1,115 @@
|
||||
import Dexie, { type Table } from 'dexie';
|
||||
|
||||
import type { key_val } from './ae_stores';
|
||||
|
||||
// li = list
|
||||
// kv = key value list
|
||||
|
||||
// Updated 2024-09-25
|
||||
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?
|
||||
|
||||
// name: null|string;
|
||||
// summary?: null|string;
|
||||
title: null|string;
|
||||
content?: null|string;
|
||||
|
||||
anonymous?: null|boolean;
|
||||
full_name?: null|string;
|
||||
email?: null|string;
|
||||
|
||||
enable_comments?: null|boolean;
|
||||
|
||||
archive?: null|boolean;
|
||||
archive_on?: Date;
|
||||
|
||||
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;
|
||||
|
||||
// Additional fields for convenience (database views)
|
||||
post_comment_count?: number;
|
||||
}
|
||||
|
||||
// Updated 2024-09-25
|
||||
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;
|
||||
|
||||
// name: null|string;
|
||||
// summary?: null|string;
|
||||
title: null|string;
|
||||
content?: null|string;
|
||||
|
||||
anonymous?: null|boolean;
|
||||
full_name?: null|string;
|
||||
email?: 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;
|
||||
|
||||
// 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<Post>;
|
||||
post_comment!: Table<Post_Comment>;
|
||||
|
||||
constructor() {
|
||||
super('ae_posts_db');
|
||||
this.version(1).stores({
|
||||
post: `
|
||||
id, post_id,
|
||||
account_id,
|
||||
topic_id, topic,
|
||||
title,
|
||||
full_name, email,
|
||||
archive, archive_on,
|
||||
enable, hide, priority, sort, group, notes, created_on, updated_on`,
|
||||
post_comment: `
|
||||
id, post_comment_id,
|
||||
post_id,
|
||||
title,
|
||||
full_name, email,
|
||||
enable, hide, priority, sort, group, notes, created_on, updated_on`,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export const db_posts = new MySubClassedDexie();
|
||||
Reference in New Issue
Block a user