// film.service.ts

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

@Injectable({
  providedIn: 'root'
})
export class OutdoorService {
  private Outdoor = Parse.Object.extend('LQLOutdoor');

 constructor() {}

 async getOutdoors(queryParams: any): Promise<Parse.Object[]> {
   const query = new Parse.Query(this.Outdoor);
   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 getOutdoors(): Promise<any[]> {
//     const Outdoor = Parse.Object.extend('Outdoor');
//     const query = new Parse.Query(Outdoor);
//     return await query.find();
//   }

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

}