IndexedDB wildcard at start and end of searchterm -
this topic explains how use wildcards ad end of searchterm using indexeddb.
i looking way add wildcard @ end , @ start of searchterm. in sql be: like '%searchterm%'
.
how can achieve indexeddb? here code:
function getmaterials() { var materialnumber = $("#input").val(); var transaction = db.transaction(["materials"]); var objectstore = transaction.objectstore("materials"); var request = objectstore.opencursor(idbkeyrange.bound(materialnumber, materialnumber + '\uffff'), 'prev'); $("#output").find("tr:gt(0)").remove(); request.onsuccess = function (event) { var cursor = event.target.result; if (cursor) { var newrow = '<tr><td>'+ cursor.value.materialnumber +'</td>'+ '<td>'+ cursor.value.description +'</td>'+ '<td>'+ cursor.value.pieces +'</td>'+ '<td>'+ cursor.value.price +'</td></tr>'; $('#output').append(newrow); cursor.continue(); } }; };
edit:
i achieve letting indexdb return rows , narrow down in javascript. there must better approach in terms of performance.
if (cursor.value.materialnumber.indexof(materialnumber) != -1){ //add result... }
this not how idb intended used. if want text searching, parse text tokens, store tokens, use index on tokens, , lookups on index pointer full text.
Comments
Post a Comment