LoginSignup
4
1

More than 1 year has passed since last update.

Dexieで部分一致で検索する方法

Posted at

Dexieで部分一致で検索する方法。

// 記述例
async function search_todo(word) {
  // Dexieの標準検索には前方一致しかないため、filterを使用して絞り込みをかける。
  const todos = await db.table.filter(function (todo) {
    // javascriptの部分一致検索方法で判定してやる。 
    return todo.title.indexOf(word) > -1;
  }).toArray();
  return await todos;
}

参照元:
https://github.com/dfahlander/Dexie.js/issues/146

以上

4
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
1