Randy7611273
Posts: 0
Joined: Sat Jun 27, 2015 7:03 pm

Where-function, Service Request to Local Storage Comparison Value

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

Bruce Stuart
Posts: 0
Joined: Fri Oct 24, 2014 4:42 am

Where-function, Service Request to Local Storage Comparison Value

How about:

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

Randy7611273
Posts: 0
Joined: Sat Jun 27, 2015 7:03 pm

Where-function, Service Request to Local Storage Comparison Value

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."

Randy7611273
Posts: 0
Joined: Sat Jun 27, 2015 7:03 pm

Where-function, Service Request to Local Storage Comparison Value

This seems to be the winner!

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

Learning, slowly but surely...

Return to “Issues”