IndexedDBStore
Defined in: src/store/indexeddb.ts:62
Extends
Section titled “Extends”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new IndexedDBStore(
opts):IndexedDBStore
Defined in: src/store/indexeddb.ts:104
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 createClientclient.startClient();client.on("sync", function(state, prevState, data) { if (state === "PREPARED") { console.log("Started up, now with go faster stripes!"); }});Parameters
Section titled “Parameters”IOpts
Options object.
Returns
Section titled “Returns”IndexedDBStore
Overrides
Section titled “Overrides”Properties
Section titled “Properties”_backend
Section titled “_backend”_backend:
IIndexedDBBackend
Defined in: src/store/indexeddb.ts:67
accountData
Section titled “accountData”accountData:
Map<string,DigitalWorldEvent>
Defined in: src/store/memory.ts:60
Inherited from
Section titled “Inherited from”clearOutOfBandMembers
Section titled “clearOutOfBandMembers”clearOutOfBandMembers:
DegradableFn<[string],void>
Defined in: src/store/indexeddb.ts:300
Overrides
Section titled “Overrides”MemoryStore.clearOutOfBandMembers
deleteAllData
Section titled “deleteAllData”deleteAllData:
DegradableFn<[],void>
Defined in: src/store/indexeddb.ts:211
Delete all data from this store.
Returns
Section titled “Returns”Promise which resolves if the data was deleted from the database.
Overrides
Section titled “Overrides”getClientOptions
Section titled “getClientOptions”getClientOptions:
DegradableFn<[],IStoredClientOpts|undefined>
Defined in: src/store/indexeddb.ts:305
Overrides
Section titled “Overrides”getOutOfBandMembers
Section titled “getOutOfBandMembers”getOutOfBandMembers:
DegradableFn<[string],IStateEventWithRoomId[] |null>
Defined in: src/store/indexeddb.ts:281
Returns the out-of-band membership events for this room that were previously loaded.
Returns
Section titled “Returns”the events, potentially an empty array if OOB loading didn’t yield any new members
Returns
Section titled “Returns”in case the members for this room haven’t been stored yet
Overrides
Section titled “Overrides”MemoryStore.getOutOfBandMembers
getSavedSync
Section titled “getSavedSync”getSavedSync:
DegradableFn<[],ISavedSync|null>
Defined in: src/store/indexeddb.ts:190
Returns
Section titled “Returns”Promise which resolves with a sync response to restore the client state to where it was at the last save, or null if there is no saved sync data.
Overrides
Section titled “Overrides”getSavedSyncToken
Section titled “getSavedSyncToken”getSavedSyncToken:
DegradableFn<[],string|null>
Defined in: src/store/indexeddb.ts:203
Returns
Section titled “Returns”If there is a saved sync, the nextBatch token for this sync, otherwise null.
Overrides
Section titled “Overrides”isNewlyCreated
Section titled “isNewlyCreated”isNewlyCreated:
DegradableFn<[],boolean>
Defined in: src/store/indexeddb.ts:195
Returns
Section titled “Returns”whether or not the database was newly created in this session.
Overrides
Section titled “Overrides”setOutOfBandMembers
Section titled “setOutOfBandMembers”setOutOfBandMembers:
DegradableFn<[string,IStateEventWithRoomId[]],void>
Defined in: src/store/indexeddb.ts:292
Stores 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
membershipEvents
the membership events to store
Returns
Section titled “Returns”when all members have been stored
Overrides
Section titled “Overrides”MemoryStore.setOutOfBandMembers
setSyncData
Section titled “setSyncData”setSyncData:
DegradableFn<[ISyncResponse],void>
Defined in: src/store/indexeddb.ts:271
setSyncData does nothing as there is no backing data store.
syncData
The sync data
Returns
Section titled “Returns”An immediately resolved promise.
Overrides
Section titled “Overrides”storeClientOptions
Section titled “storeClientOptions”storeClientOptions:
DegradableFn<[IStoredClientOpts],void>
Defined in: src/store/indexeddb.ts:309
Overrides
Section titled “Overrides”MemoryStore.storeClientOptions
userProfiles
Section titled “userProfiles”
readonlyuserProfiles:Map<string,SyncUserProfile>
Defined in: src/store/memory.ts:68
Inherited from
Section titled “Inherited from”Accessors
Section titled “Accessors”backend
Section titled “backend”Get Signature
Section titled “Get Signature”get backend():
IIndexedDBBackend
Defined in: src/store/indexeddb.ts:122
The backend instance. Call through to this API if you need to perform specific indexeddb actions like deleting the database.
Returns
Section titled “Returns”IIndexedDBBackend
Methods
Section titled “Methods”destroy()
Section titled “destroy()”destroy():
Promise<void>
Defined in: src/store/indexeddb.ts:177
Stop the store and perform any appropriate cleanup
Returns
Section titled “Returns”Promise<void>
Overrides
Section titled “Overrides”getAccountData()
Section titled “getAccountData()”getAccountData(
eventType):DigitalWorldEvent|undefined
Defined in: src/store/memory.ts:306
Get account data event by event type
Parameters
Section titled “Parameters”eventType
Section titled “eventType”string
The event type being queried
Returns
Section titled “Returns”DigitalWorldEvent | undefined
the user account_data event of given type, if any
Inherited from
Section titled “Inherited from”getFilter()
Section titled “getFilter()”getFilter(
userId,filterId):Filter|null
Defined in: src/store/memory.ts:238
Retrieve a filter.
Parameters
Section titled “Parameters”userId
Section titled “userId”string
filterId
Section titled “filterId”string
Returns
Section titled “Returns”Filter | null
A filter or null.
Inherited from
Section titled “Inherited from”getFilterIdByName()
Section titled “getFilterIdByName()”getFilterIdByName(
filterName):string|null
Defined in: src/store/memory.ts:247
Retrieve a filter ID with the given name.
Parameters
Section titled “Parameters”filterName
Section titled “filterName”string
The filter name.
Returns
Section titled “Returns”string | null
The filter ID or null.
Inherited from
Section titled “Inherited from”getOldestToDeviceBatch()
Section titled “getOldestToDeviceBatch()”getOldestToDeviceBatch():
Promise<IndexedToDeviceBatch|null>
Defined in: src/store/indexeddb.ts:393
Fetches the oldest batch of to-device messages in the queue
Returns
Section titled “Returns”Promise<IndexedToDeviceBatch | null>
Overrides
Section titled “Overrides”MemoryStore.getOldestToDeviceBatch
getPendingEvents()
Section titled “getPendingEvents()”getPendingEvents(
roomId):Promise<Partial<IEvent>[]>
Defined in: src/store/indexeddb.ts:365
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
Returns
Section titled “Returns”Promise<Partial<IEvent>[]>
Overrides
Section titled “Overrides”getRoom()
Section titled “getRoom()”getRoom(
roomId):Room|null
Defined in: src/store/memory.ts:147
Retrieve a room by its’ room ID.
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
The room ID.
Returns
Section titled “Returns”Room | null
The room or null.
Inherited from
Section titled “Inherited from”getRooms()
Section titled “getRooms()”getRooms():
Room[]
Defined in: src/store/memory.ts:155
Retrieve all known rooms.
Returns
Section titled “Returns”Room[]
A list of rooms, which may be empty.
Inherited from
Section titled “Inherited from”getRoomSummaries()
Section titled “getRoomSummaries()”getRoomSummaries():
RoomSummary[]
Defined in: src/store/memory.ts:173
Retrieve a summary of all the rooms.
Returns
Section titled “Returns”RoomSummary[]
A summary of each room.
Inherited from
Section titled “Inherited from”getSyncToken()
Section titled “getSyncToken()”getSyncToken():
string|null
Defined in: src/store/memory.ts:82
Retrieve the token to stream from.
Returns
Section titled “Returns”string | null
The token or null.
Inherited from
Section titled “Inherited from”getUser()
Section titled “getUser()”getUser(
userId):User|null
Defined in: src/store/memory.ts:192
Retrieve a User by its’ user ID.
Parameters
Section titled “Parameters”userId
Section titled “userId”string
The user ID.
Returns
Section titled “Returns”User | null
The user or null.
Inherited from
Section titled “Inherited from”getUserProfile()
Section titled “getUserProfile()”getUserProfile(
userId):Promise<SyncUserProfile|undefined>
Defined in: src/store/indexeddb.ts:401
Retrieve a stored user profile for the given user ID, if it exists.
Parameters
Section titled “Parameters”userId
Section titled “userId”string
The user ID to retrieve the profile for.
Returns
Section titled “Returns”Promise<SyncUserProfile | undefined>
The stored profile, or undefined if no profile is stored for this user ID.
Overrides
Section titled “Overrides”getUsers()
Section titled “getUsers()”getUsers():
User[]
Defined in: src/store/memory.ts:200
Retrieve all known users.
Returns
Section titled “Returns”User[]
A list of users, which may be empty.
Inherited from
Section titled “Inherited from”on(
event,handler):void
Defined in: src/store/indexeddb.ts:127
Re-exports TypedEventEmitter.on
Parameters
Section titled “Parameters”EventEmitterEvents | "degraded" | "closed"
handler
Section titled “handler”(…args) => void
Returns
Section titled “Returns”void
removeEventsFromRoom()
Section titled “removeEventsFromRoom()”removeEventsFromRoom(
roomId,eventIds):Promise<void>
Defined in: src/store/memory.ts:458
Remove all stored events matching the given IDs from the stored accumulated sync.
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
The target room.
eventIds
Section titled “eventIds”string[]
IDs of events to remove.
Returns
Section titled “Returns”Promise<void>
Inherited from
Section titled “Inherited from”MemoryStore.removeEventsFromRoom
removeRoom()
Section titled “removeRoom()”removeRoom(
roomId):void
Defined in: src/store/memory.ts:162
Permanently delete a room.
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”removeToDeviceBatch()
Section titled “removeToDeviceBatch()”removeToDeviceBatch(
id):Promise<void>
Defined in: src/store/indexeddb.ts:397
Removes a specific batch of to-device messages from the queue
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”Promise<void>
Overrides
Section titled “Overrides”MemoryStore.removeToDeviceBatch
removeUserProfiles()
Section titled “removeUserProfiles()”removeUserProfiles(
userIds):Promise<void>
Defined in: src/store/indexeddb.ts:409
Delete stored profiles for the given users.
Parameters
Section titled “Parameters”userIds
Section titled “userIds”string[]
The user IDs whose profiles should be deleted.
Returns
Section titled “Returns”Promise<void>
Overrides
Section titled “Overrides”MemoryStore.removeUserProfiles
save()
Section titled “save()”save(
force?):Promise<void>
Defined in: src/store/indexeddb.ts:245
Possibly write data to the database.
Parameters
Section titled “Parameters”force?
Section titled “force?”boolean = false
True to force a save to happen
Returns
Section titled “Returns”Promise<void>
Promise resolves after the write completes (or immediately if no write is performed)
Overrides
Section titled “Overrides”saveToDeviceBatches()
Section titled “saveToDeviceBatches()”saveToDeviceBatches(
batches):Promise<void>
Defined in: src/store/indexeddb.ts:389
Stores batches of outgoing to-device messages
Parameters
Section titled “Parameters”batches
Section titled “batches”ToDeviceBatchWithTxnId[]
Returns
Section titled “Returns”Promise<void>
Overrides
Section titled “Overrides”MemoryStore.saveToDeviceBatches
scrollback()
Section titled “scrollback()”scrollback(
room,limit):DigitalWorldEvent[]
Defined in: src/store/memory.ts:211
Retrieve scrollback for this room.
Parameters
Section titled “Parameters”The room
number
The max number of old events to retrieve.
Returns
Section titled “Returns”An array of objects which will be at most ‘limit’ length and at least 0. The objects are the raw event JSON.
Inherited from
Section titled “Inherited from”setFilterIdByName()
Section titled “setFilterIdByName()”setFilterIdByName(
filterName,filterId?):void
Defined in: src/store/memory.ts:269
Set a filter name to ID mapping.
Parameters
Section titled “Parameters”filterName
Section titled “filterName”string
filterId?
Section titled “filterId?”string
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”setPendingEvents()
Section titled “setPendingEvents()”setPendingEvents(
roomId,events):Promise<void>
Defined in: src/store/indexeddb.ts:379
Parameters
Section titled “Parameters”roomId
Section titled “roomId”string
events
Section titled “events”Partial<IEvent>[]
Returns
Section titled “Returns”Promise<void>
Overrides
Section titled “Overrides”setSyncToken()
Section titled “setSyncToken()”setSyncToken(
token):void
Defined in: src/store/memory.ts:95
Set the token to stream from.
Parameters
Section titled “Parameters”string
The token to stream from.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”setUserCreator()
Section titled “setUserCreator()”setUserCreator(
creator):void
Defined in: src/store/memory.ts:114
Set the user creator which is used for creating User objects
Parameters
Section titled “Parameters”creator
Section titled “creator”UserCreator
A callback that accepts an user-id and returns an User object
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”startup()
Section titled “startup()”startup():
Promise<void>
Defined in: src/store/indexeddb.ts:134
Returns
Section titled “Returns”Promise<void>
Resolved when loaded from indexed db.
Overrides
Section titled “Overrides”storeAccountDataEvents()
Section titled “storeAccountDataEvents()”storeAccountDataEvents(
events):void
Defined in: src/store/memory.ts:289
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.
Parameters
Section titled “Parameters”events
Section titled “events”The events to store.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”MemoryStore.storeAccountDataEvents
storeEvents()
Section titled “storeEvents()”storeEvents(
room,events,token,toStart):void
Defined in: src/store/memory.ts:222
Store events for a room. The events have already been added to the timeline
Parameters
Section titled “Parameters”The room to store events for.
events
Section titled “events”The events to store.
string | null
The token associated with these events.
toStart
Section titled “toStart”boolean
True if these are paginated results.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”storeFilter()
Section titled “storeFilter()”storeFilter(
filter):void
Defined in: src/store/memory.ts:229
Store a filter.
Parameters
Section titled “Parameters”filter
Section titled “filter”Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”storeRoom()
Section titled “storeRoom()”storeRoom(
room):void
Defined in: src/store/memory.ts:103
Store the given room.
Parameters
Section titled “Parameters”The room to be stored. All properties must be stored.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”storeUser()
Section titled “storeUser()”storeUser(
user):void
Defined in: src/store/memory.ts:183
Store a User.
Parameters
Section titled “Parameters”The user to store.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”storeUserProfiles()
Section titled “storeUserProfiles()”storeUserProfiles(
userProfiles):Promise<void>
Defined in: src/store/indexeddb.ts:405
Store user profile details from a sync. Existing profiles will be overwritten.
Parameters
Section titled “Parameters”userProfiles
Section titled “userProfiles”Map<string, SyncUserProfile>
A map of userIds to profiles.
Returns
Section titled “Returns”Promise<void>
Overrides
Section titled “Overrides”wantsSave()
Section titled “wantsSave()”wantsSave():
boolean
Defined in: src/store/indexeddb.ts:233
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().
Returns
Section titled “Returns”boolean
True if calling save() will actually save (at the time this function is called).
Overrides
Section titled “Overrides”exists()
Section titled “exists()”
staticexists(indexedDB,dbName):Promise<boolean>
Defined in: src/store/indexeddb.ts:63
Parameters
Section titled “Parameters”indexedDB
Section titled “indexedDB”IDBFactory
dbName
Section titled “dbName”string
Returns
Section titled “Returns”Promise<boolean>