Start a new topic

Phonegap DataStore does not pull value.

Hello, can someone help me, my code does not return the values me and goes straight to the "Error" function. This is the code ...

getCidade function () {

         var = Kinvey.DataStore.get promise ('city', 'Araripe');

         promise.then (function (response) {

             alert (response);

         }, Function (error) {

             alert ("Error");

         });

     }

     getCidade ();

Notice that I'm calling the function as soon as the app is open to him to bring me the values of the collection.

I thank any help. ^^


Ramon, the first line of your code looks very strange.


var = Kinvey.DataStore.get promise ('city', 'Araripe');


should probably be


var promise = Kinvey.DataStore.get('city', 'Araripe');


Thanks,

Damien, thanks for help but I corrected the error but it still remains. :(

Hello Ramon, can you print out error.description and tell me what the error is?


Thanks,

Damian, he did not give me a mistake, just do not enter the condition.

var promise = Kinvey.DataStore.get('city', 'Araripe');

I would be grateful if you could send me a ready example, because really do not know what to do or where I am going wrong. I am by setting all values according to the parameters of kinvey yet this vunciona not function. :(

Ramon,


Get only gets via ID (You can review that over here in the PhoneGap reference document:  http://devcenter.kinvey.com/phonegap/reference/api/Kinvey.DataStore.html  And see that the accepted parameters for get are:

get(collection, id, options) → {Promise}  -- (collection / id are not optional)


I believe that you are looking for something more along the lines of find...


find(collection, query, options) (where query/ options are optional)


var query = new Kinvey.Query();
query.equalTo('firstName', firstName);
var promise = Kinvey.DataStore.find('firstNames', query);


Where firstNames is the collection, and 'firstName' is the field, and firstName is the variable that you're querying for.


Does this make sense?


Thanks,

Hey Damien ran the other way. Just one problem I try to solve now.

I need to make this function to work without having a User logged in to have permission to check the values of bd.

Could you give me any tips on how to do this, I wiggled in acl but not much understand the permissions system in ambinto the practice theory I understand.

Already grateful for your help. ^^

Ramon, 


You could access the acl of the objects to be globally read / written?


http://devcenter.kinvey.com/rest/guides/security#entityanduserpermissions


Thanks,

I can, but I can not put into practice the supplied codes.

I'm really new in this mobile world and back-end framework, if you can put me an example or explocar me where should I put the right attributes in the right places, I really would be very grateful.


var entity = { prop: 'value' };

var acl = new Kinvey.Acl(entity);


I want to know what I put in place of the value?


Thanks,

Ramon:  


You should be looking at globally readable / writable (as you shouldn't need to be authenticated with anything to pull this value:  http://devcenter.kinvey.com/phonegap/guides/security#GlobalAccessControl


Simply set it to true, then do a Kinvey.DataStore.Save on the entity in question.


Thanks,

Login or Signup to post a comment