Skip to content

Instantly share code, notes, and snippets.

@phpsmarter
Created January 24, 2022 02:20
Show Gist options
  • Save phpsmarter/8e0ad1879ba2925a93968d297176f7f1 to your computer and use it in GitHub Desktop.
Save phpsmarter/8e0ad1879ba2925a93968d297176f7f1 to your computer and use it in GitHub Desktop.
var pouch = new PouchDB('mydb');
var doc = {_id : 'mydoc', title : "Guess who?", text : "It's-a me, Mario!"};
pouch.put(doc).then(function() {
return pouch.search({
query : 'mario',
fields : [ 'title', 'text' ],
include_docs : true,
highlighting : true
});
})
.then(function(res) {
console.log(res.rows[0].doc.text); // "It's-a me, Mario!"
console.log(res.rows[0].highlighting); // {"text": "It's-a me, <strong>Mario</strong>!"}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment