callback: Function function (item, cursor) { }

Callback Parameters

item: Object Found object
cursor: IDBCursor The cursor of the object being iterated.

Return Value



Iterate through all objects in the collection in an implicit single readonly transaction. If you need to modify or delete items from within the callback, you could use Collection.modify() in place of Collection.each(), since it will use a readwrite transaction rather than a readonly transaction. You could also explicitly surround your call in a READWRITE transaction.

When iteration finishes, the returned Promise will resolve with undefined, calling any Promise.then() callback.

If the operation fails, the returned Promise will be rejected, calling any Promise.catch() callback.


  • The operation will implicitly be called from within a READONLY transaction unless you already surround your code with a transaction.
  • The callback should not modify the database. If that is required, use Collection.modify() instead.
  • The return value from your callback is ignored, so returning a Promise from it will have no effect.
  • In many cases, it is better and more optimized to use any of the following methods when reading from a Table or Collection:


const db = new Dexie('dbname');

  friends: `

// Populate table
  {id: 1, name: "Foo", age: 33},
  {id: 2, name: "Bar", age: 44},
  {id: 3, name: "Someone", age: 1}
]).then(() => {
  // Iterate all friends, ordered by id:
  console.log("All my friends, ordered by id:");
  return db.friends.each(friend => console.log(;
}).then(() => {
  // Iterate all friends, ordered by age:
  console.log("All my friends, ordered by age:");
  return db.friends.orderBy('age').each(friend => console.log(;
}).then(() => {
  // Iterate all friends where age is above 30.
  console.log("Friends over 30 years old:");
  return db.friends.where('age').above(30).each(friend => console.log(;
}).catch (err => {
  console.error (err);

Table of Contents