loopbackio / loopback-connector-elastic-search

Strongloop Loopback connector for Elasticsearch
MIT License
79 stars 55 forks source link

Criteria in buildFilter function should be an object instead of string #91

Closed kamal0808 closed 7 years ago

kamal0808 commented 7 years ago

Description

The function ESConnector.prototype.buildFilter = function (modelName, idName, criteria, size, offset) expects parameter criteria to be a String as given in its description:

/**
 * Make filter from criteria, data index and type
 * Ex:
 *   {"body": {"query": {"match": {"title": "Futuro"}}}}
 *   {"q" : "Futuro"}
 * @param {String} modelName filter
 * @param {String} criteria filter
 * @param {number} size of rows to return, if null then skip
 * @param {number} offset to return, if null then skip
 * @returns {object} filter
 */

Whereas, it is explicitly used as an object inside the function.

How to recreate issue?

Use any good IDE like Webstorm, and you'll get an error while using the function that says something like this: Argument filter should be of type String

I know this is a very petty issue, but can confuse people. So I am gonna go ahead and create a pull request for the same, unless, it being String serves some purpose that I do not see.