forked from mystiq/hydrogen-web
camel-case non-matrix keys in idb stores
This commit is contained in:
parent
90b016bbcf
commit
ec6bd2ca1f
2 changed files with 9 additions and 8 deletions
|
@ -8,10 +8,11 @@ export default async function createIdbStorage(databaseName) {
|
||||||
|
|
||||||
function createStores(db) {
|
function createStores(db) {
|
||||||
db.createObjectStore("session", {keyPath: "key"});
|
db.createObjectStore("session", {keyPath: "key"});
|
||||||
// any way to make keys unique here?
|
// any way to make keys unique here? (just use put?)
|
||||||
db.createObjectStore("roomSummary", {keyPath: "room_id"});
|
db.createObjectStore("roomSummary", {keyPath: "roomId"});
|
||||||
const timeline = db.createObjectStore("roomTimeline", {keyPath: ["room_id", "sort_key"]});
|
// needs roomId separate because it might hold a gap and no event
|
||||||
timeline.createIndex("by_event_id", ["room_id", "event.event_id"], {unique: true});
|
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?
|
// 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?
|
// 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?
|
// take sort_key as primary key then and have index on event_id?
|
||||||
|
|
|
@ -35,8 +35,8 @@ class TimelineStore {
|
||||||
|
|
||||||
appendGap(roomId, sortKey, gap) {
|
appendGap(roomId, sortKey, gap) {
|
||||||
this._timelineStore.add({
|
this._timelineStore.add({
|
||||||
room_id: roomId,
|
roomId: roomId,
|
||||||
sort_key: sortKey,
|
sortKey: sortKey,
|
||||||
content: {
|
content: {
|
||||||
event: null,
|
event: null,
|
||||||
gap: gap,
|
gap: gap,
|
||||||
|
@ -46,8 +46,8 @@ class TimelineStore {
|
||||||
|
|
||||||
appendEvent(roomId, sortKey, event) {
|
appendEvent(roomId, sortKey, event) {
|
||||||
this._timelineStore.add({
|
this._timelineStore.add({
|
||||||
room_id: roomId,
|
roomId: roomId,
|
||||||
sort_key: sortKey,
|
sortKey: sortKey,
|
||||||
content: {
|
content: {
|
||||||
event: event,
|
event: event,
|
||||||
gap: null,
|
gap: null,
|
||||||
|
|
Loading…
Reference in a new issue