canjs v5.31.0 Release Notes

Release Date: 2019-08-14 // over 4 years ago
  • ๐Ÿš€ canjs/canjs v5.31.0 Release Notes

    ๐Ÿš€ This release highlights an updated can-query-logic with support for new $all, $and, and $not comparisons.

    ๐Ÿš€ can-define

    ๐Ÿš€ can-query-logic

    $all

    The $all comparison matches collections which contain all of the provided values. For example given the dataset:

    [{ "id": "Canada", "colors": [ "red", "white"] }, { "id": "Mexico", "colors": ["red", "white", "green"] }, { "id": "USA", "colors": ["red", "white", "blue"] } ]
    

    The query { colors: { $all: ["red", "white"] } } would match all 3 entries. The query { colors: { $all: ["blue"] } } would match only USA.

    $not

    The $not comparison can be used to negate any other comparison. For example given the dataset:

    [{ "name": "Joe", "age": 45 }, { "name": "Zoey", "age": 22 }]
    

    The query { age: { $not: { $lt: 40 } } } matches Joe. It is exactly equivalent to { age: { $gte: 40 } }.

    $and

    The $and comparison combines multiple other comparisons into a single grouping. It can be used in combination with the two above comparisons like so. Given the dataset:

    [{ "id": "Canada", "colors": [ "red", "white"] }, { "id": "Mexico", "colors": ["red", "white", "green"] }, { "id": "USA", "colors": ["red", "white", "blue"] } ]
    

    The query { $and: [{ colors: { $all: ["red, "white"] } }, { colors: { $not: { $all: ["blue"] } } } ] } matches Canada and Mexico.