camel-case non-matrix keys in idb stores

This commit is contained in:
Bruno Windels 2019-02-07 00:51:27 +00:00
parent 90b016bbcf
commit ec6bd2ca1f
2 changed files with 9 additions and 8 deletions

View file

@ -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?

View file

@ -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,