Page 1 of 2

using a "where" parameter to search in a local storage array

Posted: Fri May 08, 2015 12:37 am
by LuisMa Suárez Gutiérrez

hi!
I'm reading the appery musicshop tutorial ( https://devcenter.appery.io/building-... )
and I really like how the instruments appear as you type in the search bar.
I'm very interested in this :
"One of the main benefits of using the Model and Storage features is that the List service can be invoked once upon app start and retrieved data can be used further across the whole app."

i want to have the app invoke the "list" service when online and then be ready to take to the field and work offline . it should search the database but from local storage. In the tutorial every time you type in a fraction of an instruments name it triggers a remote database service.

can this be done?
exactly like that app works, but, in offline mode. use a "where" parameter against a list in local storage.

an other idea is to export the entire list as a json object and just put it inside the app. BUT,how can i look up the guests as they arrive

context: its a guestlist check in app. but wedding receptions can be in the middle of the jungle, or at a beach. so no wifi and mediocre cellphone signal so no 4g.


using a "where" parameter to search in a local storage array

Posted: Fri May 08, 2015 4:07 pm
by LuisMa Suárez Gutiérrez

Image

basically this is what i want,
after dumping from database service to local storage, map to a mobile_list but inserting a JS code like this one return "{'name':{'$regex':'(?i)."+ value +".'}}"; just like the musicshop tutorial,


using a "where" parameter to search in a local storage array

Posted: Fri May 08, 2015 6:20 pm
by Serhii Kulibaba

Hello,

Please use SQLite DB for offline mode:
https://devcenter.appery.io/tutorials...


using a "where" parameter to search in a local storage array

Posted: Mon May 11, 2015 8:13 pm
by LuisMa Suárez Gutiérrez

Hi!!
i just looked over the TodoTutorial part one and part two (offline)
also did this tutorial : https://devcenter.appery.io//building... but after adding the custom JS implementation to the generic service i get errors. please tell what im missing.
i am able to get the WebSQL tables set, but then i cant retrieve them.
Image

i have created my response parameters in the generic service. like this.
Image

my goal is simple
1 receive wedding guests at gate,
2 ask for name and look up in app: "peter baker smith"
3 as soon as I type "peter" I should get a list of all "peters" on guest list and what table to place him. I really wouldn't need to do anything to the db at this stage.

4 i'd love to search by initials, so "peter baker smith" could also be found by typing "pbs"
if i can achieve this, all other perks and enhancements would be extensions of this.


using a "where" parameter to search in a local storage array

Posted: Tue May 12, 2015 10:58 am
by Serhii Kulibaba

Can you provide more details on this error? Are there any errors in console? This: (http://devcenter.appery.io/documentat...) should help.


using a "where" parameter to search in a local storage array

Posted: Wed May 13, 2015 4:20 pm
by LuisMa Suárez Gutiérrez

Hi!
the error i had is because i assigned the same settings as the online DB
Image ,

i solved this part of the equation , the one that really had me in a twist. the next part should be easy. i detailed what i was missing for karma's sake :

the js implementation i copied from the appery SQLite tutorial dumped the JSON in to console. like this:

"console.log("Tables: " + JSON.stringify(ourFinalArray)); "

see image below and see console has the JSON object
Image

so i created my return parameters

Image

and lastly , this is the step i didnt do , i needed to use the console dump and assign it as an echo, so the service knows what im expecting
Image

and now, it works like a charm


using a "where" parameter to search in a local storage array

Posted: Thu May 14, 2015 1:24 am
by LuisMa Suárez Gutiérrez

now I get the app to list all items from local storage successfully,
the curious thing is , it can access the storage without downloading it first.
so far this is my app. i am elated. and overcaffeinate.

now i need to be able to filter as i type. this is a screenshot of a similar app.

Image

this is my overall plan, to run a SQL query with the "searchbar.text" property on a "{'name':{'$regex':'(?i)."+ searchbar.text +".'}}"; expression.

on seachbar's search event, though i dont know how much syntax i need to run SQL in appery or how to map that back to the list.
i believe this is very concrete to ask. can you help me?

Image


using a "where" parameter to search in a local storage array

Posted: Thu May 14, 2015 12:58 pm
by Serhii Kulibaba

"{'name':{'$regex':'(?i)."+ searchbar.text +".'}}"

It is incorrect usage of SQLite.
Please use LIKE to search data in local DB:

http://www.tutorialspoint.com/sqlite/...


using a "where" parameter to search in a local storage array

Posted: Thu May 14, 2015 3:00 pm
by LuisMa Suárez Gutiérrez

sorry , it was intended as pseudo code.

i used the SQLite tutorial you mentioned and temporarily changed the JS implementation of the generic service using

SELECT FROM "Tables" WHERE "nombre" LIKE "pedro"

to see if i can filter out the results.
i did this because the service was already mapped to the list.but it doesnt work, it keeps displaying the entire table

Image

do i have to use this entire code each time i search? or can i just use
something similar to :

var db = window.openDatabase("Wedding 0.3", "", "Wedding 0.3", 1024*1000);
localStorage.searchResult =tx.executeSql('SELECT FROM "Tables" WHERE "nombre" LIKE "pedro";' , [], function(tx, results)


using a "where" parameter to search in a local storage array

Posted: Thu May 14, 2015 7:36 pm
by Evgene Karachevtsev

Hello LuisMa,

Sorry, I'm not sure I understand you correctly, could you please clarify do you need further help? Could you please specify your question in this case?