Skip to content

Latest commit

 

History

History
72 lines (59 loc) · 1.06 KB

File metadata and controls

72 lines (59 loc) · 1.06 KB

Query rows from a table

Querying can be achieved using an $idbID, an array of $idbID, or a custom function, or nothing in which case it will return everything. Querying is done asynchronously, so it will return a promise that will resolve to queried data.

Using no filter

table.query()
  .then(rows => console.log(rows));

// [
//   {
//     $idbID: 1,
//     column: 'column 1'
//   },
//   {
//     $idbID: 2,
//     column: 'column 2'
//   },
//   {
//     $idbID: 3,
//     column: 'column match'
//   }
// ]

Using id

table.query(1)
  .then(rows => console.log(rows));

// [
//   {
//     $idbID: 1,
//     column: 'column 1'
//   }
// ]

Using ids

table.query([1, 2])
  .then(rows => console.log(rows));

// [
//   {
//     $idbID: 1,
//     column: 'column 1'
//   },
//   {
//     $idbID: 2,
//     column: 'column 2'
//   }
// ]

Using a function

table.query(row => row.column === 'column match')
  .then(rows => console.log(rows));

// [
//   {
//     $idbID: 3,
//     column: 'column match'
//   }
// ]