// film.service.ts

import { Injectable } from '@angular/core';
import Parse from 'parse';

@Injectable({
  providedIn: 'root'
})
export class GameService {
  private Game = Parse.Object.extend('LQLGame');

 constructor() {}

 async getGames(queryParams: any): Promise<Parse.Object[]> {
   const query = new Parse.Query(this.Game);
   if (queryParams.name) {
     query.contains('name', queryParams.name);
   }
   if (queryParams.author) {
     query.equalTo('aouhor', queryParams.aouhor);
   }
   if (queryParams.sortByrating) {
     query.ascending('rating');
   } else {
     query.descending('rating');
   }
   return await query.find();
 }

//   async getGames(): Promise<any[]> {
//     const Game = Parse.Object.extend('Game');
//     const query = new Parse.Query(Game);
//     return await query.find();
//   }

//   async getSortedGamesByRating(): Promise<any[]> {
//     const Game = Parse.Object.extend('Game');
//     const query = new Parse.Query(Game);
//     query.descending('rating');
//     return await query.find();
//   }

}