Reading and Writing Data
Read and writing data with Indesely, just like IndexedDB, starts with a transaction. Once a transaction is started, you may read or write data to the database depending on the kind of transaction.
Starting Transactions
Transactions come in three flavors; read-only, read/write, and upgrade. The read-only, read/write transaction are the ones you will use to read and write data during normal operations. Upgrade transactions are only available during migrations, which can also perform most of same functions as read/write transactions.
To start a transaction, you will call either Database.read
or Database.change
with a list of object store you will interact with. For example:
// Start a read-only transaction.
db.read(['employees'], async (trx) => {
/* ... */
});
// Start a read/write transaction.
db.change(['employees'], async (trx) => {
/* ... */
});
Any attempt to interact with any store other than the ones specified will result in an error.
You can learn more about them upgrade transaction by reading about Migrations.
Inserting and Updating Records
INFO
Coming soon! See the Update Query Builder API Reference for now.
Reading Records and Keys
INFO
Coming soon! See the Select Query Builder API Reference for now.
Querying on Keys and Indices
INFO
Coming soon! See the Select Query Builder API Reference for now.
Deleting Records
INFO
Coming soon! See the Delete Query Builder API Reference for now.
What's Next?
- Learn how to list and delete database by reading Managing Database.