Use Cloud function instead instead of parse on client sdks?

Hello Parse Community!

This is going to be my first post, so a quick introduction: I’m a junior mobile developer who has still a lot to learn.My friend and I found the gold mine which is parse a year ago and it’s been amazing since. We could develop great apps because of it! The journey of developers is an exciting one and what I like is that we always look forward to learn new things and improve our methods. Hence I need to ask you a question : Considering that I’m an android developer and my friend an iOS developer each one is still using parse own sdk for each platform. But wouldn’t it be better if we implement all the code that requires an interaction with the database with cloud function so it’s just in one place instead ?
Thank you for your responses and long live the parse community! :tada:

I can recommend to move (most of) the Parse code to CloudCode functions. The only downside IMO is that when you add a new feature, you have to touch three codebases (both of your apps + the backend); so for prototyping features you still might want to start coding client-side and then transfer the logic to CloudCode later on. But in general, terms of maintainability and testability it works great.

Hey,

Cloud Code is the place where your business logic should be placed. If you have for example cloud code function “getUsersWithAvatar” where you filter your users by existing avatar. It will be simple to call this function from your iOS, Android, Web etc. apps and just get the payload and do whatever you want with it in your frond-end (iOS, Android, Web etc.).

So … in short … Yes! Parse Cloud Code is your friend :slight_smile:

Hope this will help you :slight_smile:

1 Like

Hey guys, thank you for your replies. Will definitely start looking more into cloud coding! :slight_smile:

1 Like

But let’s say I want to edit an object. when using the client sdk I already have an instance of parseobject I can edit and save. But if we’re using the implementation of cloud code can’t pass the object so I have to pass the object id and query it again. Is there another efficient way to do it ?

You can do something like this:

Parse.Cloud.define('updateObject', async request => {
  const obj = new Parse.Object('SomeClass', { id: request.params.id });
  obj.set('someField', 'some updated value');
  await obj.save();
});
1 Like

David! Thank you so much for your answer! Much appreciated :slight_smile:

In brief, yes absolutely! We did this a long time ago and don’t run any client side Parse SDKs across Web, iOS and Android. Just have endpoints, API calls and we’re having a great time of it.

If there is anything in particular you want to know / have an example of then let me know and I will add some code if I have an example handy.

1 Like

Yes we opted for that option too. Thank you for your answer Simon!