diff --git a/src/storage/idb/create.js b/src/storage/idb/create.js index a87636da..6ee0a5c9 100644 --- a/src/storage/idb/create.js +++ b/src/storage/idb/create.js @@ -8,10 +8,11 @@ export default async function createIdbStorage(databaseName) { function createStores(db) { db.createObjectStore("session", {keyPath: "key"}); - // any way to make keys unique here? - db.createObjectStore("roomSummary", {keyPath: "room_id"}); - const timeline = db.createObjectStore("roomTimeline", {keyPath: ["room_id", "sort_key"]}); - timeline.createIndex("by_event_id", ["room_id", "event.event_id"], {unique: true}); + // any way to make keys unique here? (just use put?) + db.createObjectStore("roomSummary", {keyPath: "roomId"}); + // needs roomId separate because it might hold a gap and no event + const timeline = db.createObjectStore("roomTimeline", {keyPath: ["roomId", "sortKey"]}); + timeline.createIndex("byEventId", ["roomId", "event.event_id"], {unique: true}); // how to get the first/last x events for a room? // we don't want to specify the sort key, but would need an index for the room_id? // take sort_key as primary key then and have index on event_id? diff --git a/src/storage/idb/stores/timeline.js b/src/storage/idb/stores/timeline.js index 7a1eeadd..29b6e09e 100644 --- a/src/storage/idb/stores/timeline.js +++ b/src/storage/idb/stores/timeline.js @@ -35,8 +35,8 @@ class TimelineStore { appendGap(roomId, sortKey, gap) { this._timelineStore.add({ - room_id: roomId, - sort_key: sortKey, + roomId: roomId, + sortKey: sortKey, content: { event: null, gap: gap, @@ -46,8 +46,8 @@ class TimelineStore { appendEvent(roomId, sortKey, event) { this._timelineStore.add({ - room_id: roomId, - sort_key: sortKey, + roomId: roomId, + sortKey: sortKey, content: { event: event, gap: null,