html5 - in indexed database, how to get a keysList in which key start with "some string"? -


function fetchemployeebyemail() {   try {     var result = document.getelementbyid("result");     result.innerhtml = "";      if (localdatabase != null && localdatabase.db != null) {         var range = idbkeyrange.lowerbound("john");          var store = localdatabase.db.transaction("employees").objectstore("employees");         var index = store.index("emailindex");          index.get(range).onsuccess = function(evt) {             var employee = evt.target.result;              var jsonstr = json.stringify(employee);             result.innerhtml = jsonstr;            };     }   }   catch(e){     console.log(e);   } } 

in above sample, how emails have first name "john"????

a nosql approach databases means should think alternate storage access patterns. if want support query first name, , want in performant manner, consider storing derived first name property per employee, create index on derived property, , query index.

storing derived property redundant 1 point of view, sure. intuitively feels normalization violation. however, idea here disk space cheap , available time not. can make trade off in space time want. have 2 ways:

  1. don't store derived property. in query, loop on employees. each employee, access email property, check, push value array if meets condition, , array of matches.
  2. redundantly store first-name property in employee store. create index on first-name property. access store via index , condition.

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -