LuisMa Suárez Gutiérrez
Posts: 0
Joined: Mon Aug 18, 2014 9:12 pm

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

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.

LuisMa Suárez Gutiérrez
Posts: 0
Joined: Mon Aug 18, 2014 9:12 pm

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

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,

LuisMa Suárez Gutiérrez
Posts: 0
Joined: Mon Aug 18, 2014 9:12 pm

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

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.

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

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

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

LuisMa Suárez Gutiérrez
Posts: 0
Joined: Mon Aug 18, 2014 9:12 pm

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

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

LuisMa Suárez Gutiérrez
Posts: 0
Joined: Mon Aug 18, 2014 9:12 pm

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

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

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

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

"{'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/...

LuisMa Suárez Gutiérrez
Posts: 0
Joined: Mon Aug 18, 2014 9:12 pm

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

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)

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

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

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?

Return to “Issues”