1

Does backbone collections using .where() or like function accept some form of less/greater-than statements such as <=, >=, <, >

I cant find anything in the documentation that says anything either way

chris
  • 36,115
  • 52
  • 143
  • 252

1 Answers1

2

No, where doesn't support that. From the fine manual:

where collection.where(attributes)

Return an array of all the models in a collection that match the passed attributes. Useful for simple cases of filter.

where is just a filter call in disguise so you can use filter (which is mixed into Backbone collections) directly for more complicated things:

var matches = collection.filter(function(m) {
    /* check model `m` here */
});
mu is too short
  • 426,620
  • 70
  • 833
  • 800
  • This is what Im finding looking at underscores docs. Now Im just trying to figure out how to do multiple parameters at once. Since the filters I am trying to create have a requirement to support multiple values to search against example: Status = Error, TimeStamp <= xxx, Location = yyy (multiple values at once, that may not always exist in the condition) – chris Jan 06 '16 at 20:31
  • @chris use `if`, `||`, `&&` etc you define your conditions... `if(Status == 'Error' || (TimeStamp <= xxx && Location == yyy)) return true; else if(){}` and so on. – T J Jan 07 '16 at 04:35