Some PouchDB sugar around lunr.js
npm install pouchdb pouchdb-lunr
import PouchDB from 'pouchdb';
import LunrPlugin from 'pouchdb-lunr';
PouchDB.plugin(LunrPlugin);
const db = new PouchDB('mydb');
db.lunr('fruits', function() {
this.field('name');
}, function(idx, doc) {
if (doc.type === 'fruit') {
idx.add({
id: doc._id,
name: doc.name
});
}
});
db.lunrSearch('fruits', 'banana').then(function(res) {
//res has same properties as db.allDocs()
});
Niklas Närhinen
MIT License