Add unique ID per post and an index to the db for that
This commit is contained in:
@@ -36,6 +36,7 @@ export function openDatabase(userID:string): Promise<IDBDatabase> {
|
||||
if (!db.objectStoreNames.contains(storeName)) {
|
||||
let store = db.createObjectStore(storeName, { keyPath: "id", autoIncrement: true });
|
||||
store.createIndex("datetimeIndex", "post_timestamp", { unique: false });
|
||||
store.createIndex("postIDIndex", "data.post_id", { unique: true });
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
@@ -16,6 +16,7 @@ declare let marked: any;
|
||||
|
||||
class Post {
|
||||
post_timestamp: Date;
|
||||
post_id: string;
|
||||
author: string;
|
||||
author_id: string;
|
||||
text: string;
|
||||
@@ -27,6 +28,7 @@ class Post {
|
||||
|
||||
constructor(author: string, author_id: string, text: string, post_timestamp: Date, imageData: ArrayBuffer | null = null, importedFrom: "twitter" | null = null, importSource: any = null) {
|
||||
this.post_timestamp = post_timestamp;
|
||||
this.post_id = generateID();
|
||||
|
||||
this.author = author;
|
||||
this.author_id = author_id;
|
||||
|
||||
Reference in New Issue
Block a user