create instance of your singleton JsonStoredatabase If you need to supply your own database for whatever reason (maybe mocking or something)
dbLocation If you want to use a different location for the DB file (default: ApplicationDocumentsDirectory)
dbName Provide a custom database file name (default: json_store)
inMemory If you don't want to store to disk but rather have it all in memory (default: false)
Function to retrieve a list of objects from the database stored under a similar key.
example:
Message list could be retrieved like this
await jsonStore.getListLike('message%');
//this should return a list based on the following data
| key | value |
| message-1 | ... |
| message-2 | ... |
| message-3 | ... |
This function will store any data as a single json object in the database.
We will try and update the key first and then insert if none exists
key the key of your item used to be retrieved later
value json Map of your value object
encrypt should the value be encrypted (default: false)
timeToLive how long should the data be considered valid (default: null)
If you getItem and the TTL has expired null will be returned and it will be removed from the database
if timeToLive is null the data will never expire
batch for transaction control where many setItem operations can be done in batch and commited at the end. see startBatch
This function will create a Batch object, this allowed you to do some sort of transaction control.
example:
var b = await jsonStore.startBatch();
await jsonStore.setItem('key', value1, batch: b);
await jsonStore.setItem('key', value2, batch: b);
await jsonStore.setItem('key', value3, batch: b);
await jsonStore.commitBatch(b);