diff --git a/backend/proxy/movie.js b/backend/proxy/movie.js index 9b7e7a7..a858d36 100644 --- a/backend/proxy/movie.js +++ b/backend/proxy/movie.js @@ -33,25 +33,25 @@ function getSearchString(searchString, priority) { } exports.getMovieByTitleCount = function (searchString) { - var rawString = searchString; + var rawString = searchString.trim(); return Movie.count({ - where: sequelize.literal('"movies"."title" ILIKE \'' + getSearchString(rawString, 1) + '\' OR ' + - '"movies"."title" ILIKE \'' + getSearchString(rawString, 2) + '\' OR ' + - '"movies"."title" ILIKE \'' + getSearchString(rawString, 3) + '\' OR ' + - '"movies"."title" ILIKE \'' + getSearchString(rawString, 4) + '\' OR ' + - '"movies"."title" ILIKE \'' + getSearchString(rawString, 5) + '\'') + where: { + title: { + $ilike: '%' + rawString + '%' + } + } }) }; exports.getMovieByTitle = function (userId, searchString, offset, limit) { - var rawString = searchString; + var rawString = searchString.trim(); return Movie.findAll({ - where: sequelize.literal('"movies"."title" ILIKE \'' + getSearchString(rawString, 1) + '\' OR ' + - '"movies"."title" ILIKE \'' + getSearchString(rawString, 2) + '\' OR ' + - '"movies"."title" ILIKE \'' + getSearchString(rawString, 3) + '\' OR ' + - '"movies"."title" ILIKE \'' + getSearchString(rawString, 4) + '\' OR ' + - '"movies"."title" ILIKE \'' + getSearchString(rawString, 5) + '\''), + where: { + title: { + $ilike: '%' + rawString + '%' + } + }, limit: limit, offset: offset, include: [ @@ -89,13 +89,13 @@ exports.getMovieByTitle = function (userId, searchString, offset, limit) { exports.getShowingMovieByTitle = function (userId, searchString) { - var rawString = searchString; + var rawString = searchString.trim(); return Movie.findAll({ - where: sequelize.literal('"movies"."title" ILIKE \'' + getSearchString(rawString, 1) + '\' OR ' + - '"movies"."title" ILIKE \'' + getSearchString(rawString, 2) + '\' OR ' + - '"movies"."title" ILIKE \'' + getSearchString(rawString, 3) + '\' OR ' + - '"movies"."title" ILIKE \'' + getSearchString(rawString, 4) + '\' OR ' + - '"movies"."title" ILIKE \'' + getSearchString(rawString, 5) + '\''), + where: { + title: { + $ilike: '%' + rawString + '%' + } + }, include: [ { model: PublicRate,