// film.service.ts

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

@Injectable({
  providedIn: 'root'
})
export class MusicService {
  private Music = Parse.Object.extend('LQLMusic');

 constructor() {}

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

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

}