Write Cloud Code on Parse Server

I am using Parse Server as BaaS for my application written with Ionic 3 and Angular 4. I have used to write my queries on Client Side and store with a provider the results locally to consume them by the users.

Now I have been advised to run the queries (and maybe the localstorage functions ???) on the Server with Cloud Code.

So my question is how to write them on the Server of Parse and what about the concept of the localstorage

Here is my search.ts to make the query and consume the results from localstorage

initializeItems() {
  this.users= this.localdata.tmpusers;

constructor(public navCtrl: NavController, private localdata: localData) {
  this.searchControl = new FormControl;
  this.query.find().then(data => {
  this.tmp = data; 

  this.users = this.localdata.tmpusers;
  console.log (this.users);

and here is my localdata.ts to save the results from the query and consume them

setUsers (users){
    window.localStorage.users_data = JSON.stringify(users);
   return JSON.parse(window.localStorage.users_data || '[]');

tmpusers = this.getUsers();
    this.tmpusers.sort(function(a, b) {
        var nameA = a.username.toUpperCase(); // ignore upper and lowercase
        var nameB = b.username.toUpperCase(); // ignore upper and lowercase
        if (nameA < nameB) {
          return -1;
        if (nameA > nameB) {
          return 1;

        // names must be equal
        return 0;

So how should I proceed with Cloud Code and localstorage for the best performance?

Thank you very much