Construct a new Indexed Database store, which extends MemoryStore.
This store functions like a MemoryStore except it periodically persists the contents of the store to an IndexedDB backend.
All data is still kept in-memory but can be loaded from disk by calling
startup()
. This can make startup times quicker as a complete
sync from the server is not required. This does not reduce memory usage as all
the data is eagerly fetched when startup()
is called.
let opts = { indexedDB: window.indexedDB, localStorage: window.localStorage };
let store = new IndexedDBStore(opts);
let client = sdk.createClient({
store: store,
});
await store.startup(); // load from indexed db, must be called after createClient
client.startClient();
client.on("sync", function(state, prevState, data) {
if (state === "PREPARED") {
console.log("Started up, now with go faster stripes!");
}
});
Options object.
Readonly
backendThe backend instance. Call through to this API if you need to perform specific indexeddb actions like deleting the database.
Protected
Optional
createDelete all data from this store.
Returns the out-of-band membership events for this room that were previously loaded.
Protected
Optional
Readonly
localStores the out-of-band membership events for this room. Note that it still makes sense to store an empty array as the OOB status for the room is marked as fetched, and getOutOfBandMembers will return an empty array instead of null
setSyncData does nothing as there is no backing data store.
Stop the store and perform any appropriate cleanup
Get account data event by event type
The event type being queried
the user account_data event of given type, if any
Retrieve a filter ID with the given name.
The filter name.
The filter ID or null.
Fetches the oldest batch of to-device messages in the queue
Retrieve a room by its' room ID.
The room ID.
The room or null.
Retrieve the token to stream from.
The token or null.
Retrieve a User by its' user ID.
The user ID.
The user or null.
Re-exports TypedEventEmitter.on
Permanently delete a room.
Removes a specific batch of to-device messages from the queue
Possibly write data to the database.
True to force a save to happen
Promise resolves after the write completes (or immediately if no write is performed)
Stores batches of outgoing to-device messages
Retrieve scrollback for this room.
The matrix room
The max number of old events to retrieve.
An array of objects which will be at most 'limit' length and at least 0. The objects are the raw event JSON.
Set a filter name to ID mapping.
Optional
filterId: stringSet the token to stream from.
The token to stream from.
Set the user creator which is used for creating User objects
A callback that accepts an user-id and returns an User object
Resolved when loaded from indexed db.
Store user-scoped account data events. N.B. that account data only allows a single event per type, so multiple events with the same type will replace each other.
The events to store.
Store events for a room. The events have already been added to the timeline
The room to store events for.
The events to store.
The token associated with these events.
True if these are paginated results.
Store the given room.
The room to be stored. All properties must be stored.
Whether this store would like to save its data Note that obviously whether the store wants to save or not could change between calling this function and calling save().
True if calling save() will actually save (at the time this function is called).
Static
exists
A store for most of the data js-sdk needs to store, apart from crypto data