Added filters/query operations for smarter database methods. Implementation is heavily based on LoopBack queries, but with some noticeable differences (see the filtering section in the readme for details).
The structure of the objects returned by the add/remove/update functions in the Model class have not changed. However, the filter parameter has changed, which will be an issue with users of older versions. As well, the implementation of finding what rows need to be used in the find/remove/update query has changed dramatically, using the Filter class. As well, the filter parameter has been removed from Mode.add() since it was not used and the parmas parameter has been removed from Model.find() and Model.get(), as it's functionality is replaced by the skip and limit filters.
Before rows of a model were compared one-to-one to elements of a filter object to check if it was a valid candidate for the find/remove/update operation. Now the entire row is used as a parameter along with a filter object (see the LoopBack documentation above) as parameters to the Filter.apply(set, settings) function, which returns a subset of passed set. The elements in this subset are determined by the various properties in the passed filter. Desired logical operations/comparisons used are in the where property, including/excluding properties in those elements as determined in the fields property, sorted by multiple ascending or descending values (using the assumably stable array.sort() method) in the order filter, and able to take a slice of that subset using the offset and limit filter. Proper application and output of various filters can be seen in docs/test.js.
Besides the lacking features of the near, like, and nlike filters in LoopBack, the filter feature is intended to work exactly the same. (except for the nested object drawbacks, see the Filter section of the readme). Therefore, even though not all use cases of the Filter class were covered in the docs/test.js, all relevant examples in the LoopBack documentation are intended to work.
If there is anything wrong, please do not hesitate to ask! Thank you for reading.
Added filters/query operations for smarter database methods. Implementation is heavily based on LoopBack queries, but with some noticeable differences (see the filtering section in the readme for details).
The structure of the objects returned by the add/remove/update functions in the
Model
class have not changed. However, thefilter
parameter has changed, which will be an issue with users of older versions. As well, the implementation of finding what rows need to be used in the find/remove/update query has changed dramatically, using theFilter
class. As well, thefilter
parameter has been removed fromMode.add()
since it was not used and theparmas
parameter has been removed fromModel.find()
andModel.get()
, as it's functionality is replaced by theskip
andlimit
filters.Before rows of a model were compared one-to-one to elements of a
filter
object to check if it was a valid candidate for the find/remove/update operation. Now the entire row is used as a parameter along with afilter
object (see the LoopBack documentation above) as parameters to theFilter.apply(set, settings)
function, which returns a subset of passed set. The elements in this subset are determined by the various properties in the passed filter. Desired logical operations/comparisons used are in thewhere
property, including/excluding properties in those elements as determined in thefields
property, sorted by multiple ascending or descending values (using the assumably stable array.sort() method) in theorder
filter, and able to take a slice of that subset using theoffset
andlimit
filter. Proper application and output of various filters can be seen indocs/test.js
.Besides the lacking features of the
near
,like
, andnlike
filters in LoopBack, the filter feature is intended to work exactly the same. (except for the nested object drawbacks, see the Filter section of the readme). Therefore, even though not all use cases of theFilter
class were covered in thedocs/test.js
, all relevant examples in the LoopBack documentation are intended to work.If there is anything wrong, please do not hesitate to ask! Thank you for reading.