Start a new topic

Share code between custom endpoints

Hello

Is there a way to share code between different endpoints in order to avoid duplicating the code?

i m trying to query the reference client side using :



var query = new $kinvey.Query();

query.equalTo('owner._id', user._id);

return $kinvey.DataStore.find('missions', query);





using user.id.toString(), made it work ! Thanks and congrats for the awesome platform and the prompt support :)
Right, but where are you trying to actually view/retrieve the reference?
I m trying to set the reference in the endpoint
Try setting the "id" property to user.id.toString().



Are you trying to resolve the reference on the client, or in the endpoint?
Thanks for the prompt answer. I am facing another issue :



i am porting some client side code to a custom endpoint where i was linking a collection object to a user using :



mission.owner=user;

return $kinvey.DataStore.save('missions', mission, { exclude : ['owner'], relations : { owner : 'user' } });



on the custom end point i try to do this:



collectionAccess.collection('missions').save(mission, { exclude : ['owner'], relations : { owner : 'user' } });



but it was saving the entire user object inside the mission so i tried to do this:



mission.owner={"_type":"KinveyRef","_collection":"user","_id":user._id};

collectionAccess.collection('missions').save(mission);



But when i do the this, any query for the client side will not retrieve my mission based on the owner._id ...

Any idea on how to port the relation to a custom endpoint?
Yes, if you use the Business Logic CLI to manage your BL, you can upload common code to be used across endpoints and collection hooks.



http://devcenter.kinvey.com/ios/tutorials/business-logic-revisions#Addingcommoncode
Login or Signup to post a comment