Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

save to db

Hi Michael,

In Database, "addresses" column has type = "array". You're trying to save string there.

You should convert the data to array in mapping.In front of Request parameter "addresses" click "Add JS" and paste the following code:codereturn [value];/code
The value selected in Select Menu will be saved in Database.

Michael4771079
Posts: 0
Joined: Sat Jul 21, 2012 2:03 pm

save to db

Thanks Katya,
something working
i have added the js,

in db,user test, addresses result is ["London","New Yourk","Rome"]

when I save addresses to other user the result is
[""]

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

save to db

Michael,

The user with correct values was created by our devs. An empty value [""] was saved after empty value was selected in addressselectmenu.

If you want to save in database an array of created favourite adresses, you should in mapping, in front of Request parameter "addresses" replace the JS that I adviced with the following JavaScript code that will get addresses data from the localStorage variable:
codereturn JSON.parse(localStorage.getItem("variable_name"));/code

Michael4771079
Posts: 0
Joined: Sat Jul 21, 2012 2:03 pm

save to db

Cheers Katya,

thats brill, works very well
the last bit is this

how do I get all the users details to load to localstorage from db on login?

thanks for all your help, you, all at tiggzi are the best support there is!

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

save to db

To get all the users details to load to localstorage from db on login you should create Rest Service with the following parameters:
codeURL: {database_url}/users/{object_id}
Method: GET
Settings: choose database settings from the dropdown list./code
Image

In Request parameters should be:
codeX-Tiggzi-Database-Id = {database_id}
X-Tiggzi-Session-Token
object_id/code
Image

Response parameters should be like the following:
Image

Such service can be used to get user data from database. Request parameter object_id should be mapped to localStorage variable "userId".

Michael4771079
Posts: 0
Joined: Sat Jul 21, 2012 2:03 pm

save to db

Hi Katya,
sorry about this,
I have done the above, and exported ipa, but the db info is not on phone,i.e addresses,name,email and mobile, all components are empty,
when I login on phone successfully I am taken to settings screen,
on load I have invoked the service,
do I need more mapping to make this work?

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

save to db

You save addresses to database. Do you restore these addresses when logging in?
You should map response parameter "addresses" to localStorage variable used in app.

Michael4771079
Posts: 0
Joined: Sat Jul 21, 2012 2:03 pm

save to db

Hi Katya,
the variable used for addresses is "variable_name" I can see it in the dom but
this variable is not in the mapping screen to enable me to map to it from the db,
sorry about this I'm having a blonde one!

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

save to db

Michael,

If there is no "variable_name" variable in mapping interface then you have to add it. This won't break existing variables and code.

After adding you can use this variable in mapping.

Michael4771079
Posts: 0
Joined: Sat Jul 21, 2012 2:03 pm

save to db

Katya,
I not getting this,
I have added the variable,created the service as per you advice, but no result, I maybe looking at this for to long, not seeing my mistake,

Return to “Issues”