You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/can-query-logic.md
+32-4Lines changed: 32 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -77,8 +77,10 @@ format. It supports a variety of operators and options. It looks like:
77
77
@param {function|can-reflect/schema} schemaOrType Defines the behavior of
78
78
keys on a [can-query-logic/query]. This is done with either:
79
79
80
-
- A constructor function that supports the `can.getSchema` symbol. Currently, [can-define/map/map] supports the `can.getSchema` symbol:
80
+
- A constructor function that supports [can-reflect.getSchema can-reflect.getSchema]. Currently, [can-define/map/map] supports the `can.getSchema` symbol:
81
81
```js
82
+
import {DefineMap} from"can";
83
+
82
84
constTodo=DefineMap.extend({
83
85
id: {
84
86
identity:true,
@@ -87,10 +89,11 @@ keys on a [can-query-logic/query]. This is done with either:
87
89
name:"string",
88
90
complete:"boolean"
89
91
});
90
-
newQuery(Todo);
92
+
newQueryLogic(Todo);
91
93
```
92
-
-A schema object that looks like:
94
+
-A[can-reflect.getSchemaschema object] that looks like the following:
93
95
```js
96
+
import {MaybeNumber, MaybeString, MaybeBoolean} from "can"
94
97
new QueryLogic({
95
98
// keys that uniquely represent this type
96
99
identity: ["id"],
@@ -102,8 +105,33 @@ keys on a [can-query-logic/query]. This is done with either:
102
105
})
103
106
```
104
107
108
+
Note that if a key type (ex:`name: MaybeString`) is __not__ provided, filtering by that
109
+
key will still work, but there won't be any type coercion. For example, the following
110
+
might not produce the desired results:
111
+
112
+
```js
113
+
var queryLogic = new QueryLogic({identity: ["id"]});
0 commit comments