IndexedDB
Docs HomeProduct SiteSupport
  • WireBootstrap IndexedDB Connector
  • Installation
  • Service Provider
  • Data Source
  • Collection
Powered by GitBook
On this page
  • Data Source
  • Query

Data Source

PreviousService ProviderNextCollection

Last updated 3 years ago

IndexedDB can be used with a traditional to query data in stores. It can also be used as a into the IndexedDB object repository.

The following example illustrates the steps needed to query data inside an IndexedDB store using a data source.

Data Source

First, create the data source that uses the IndexedDB Connector's service provider. If the store does not yet exist, a new store can be created using the .

// create an array of objects
const fruits = [
 { name: "grapes", color: "green"},
 { name: "bananas", color: "yellow"},
 { name: "apples", color: "red"},
];

// create an IndexedDB store and add the array of objects to the it
const source = new wire.data.DataSource("indexed-db", {
  Provider: {
     stores: [
          { name: "My Store", data: fruits }
      ]}
});

Query

// create the query
const query = wire.data.select()
    .from("My Store")
    .where().eq("name", "apples");

// run it against IndexedDB
const table = await source.execAsync(query);

Next, create a and then execute the query against IndexedDB. The query will return a . In the query, the store name is specified in the from clause.

WireBootstrap select query
WireBootstrap DataTable
WireBootstrap data source
collection
provider's data source configuration