Page 1 of 1

Where-function, Service Request to Local Storage Comparison Value

Posted: Sat Jul 04, 2015 2:47 pm
by Randy7611273

Hello!

I am attempting to decrement the value of all in a column (“songseq”) on the database where the number is greater than the value of a local storage item (also “songseq”). The following hardcode with a fixed value (ex: 1) works:

return "{'songseq':{'$gte':1}}";

Thus far, I’ve failed to replace the fixed value with that of the local storage item. Example:

return "{'songseq':{'$gt':"' +localStorage.getItem("songseq")+ '"}}";

Thanks in advance for your help! Image Image


Where-function, Service Request to Local Storage Comparison Value

Posted: Sat Jul 04, 2015 4:23 pm
by Bruce Stuart

How about:

return "{'songseq':{'$gt':"' +Number(localStorage.getItem("songseq")) + '"}}";


Where-function, Service Request to Local Storage Comparison Value

Posted: Sat Jul 04, 2015 4:32 pm
by Randy7611273

Thank you, Bruce, but no joy. The JS editor throws a couple of errors ("Missing Semicolon" and "Expected an assignment or function call and instead saw an expression."), and the testing the app results in "Uncaught SyntaxError: Unexpected string."


Where-function, Service Request to Local Storage Comparison Value

Posted: Sat Jul 04, 2015 10:13 pm
by Randy7611273

This seems to be the winner!

return "{'songseq':{'$gt':"+ localStorage.getItem("songseq")+ "}}";

Learning, slowly but surely...