sproutcore 1.5.0.rc.1 → 1.5.0.rc.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +4 -0
- data/VERSION.yml +1 -1
- data/lib/frameworks/sproutcore/Buildfile +9 -4
- data/lib/frameworks/sproutcore/README.md +1 -0
- data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/QuickLook/Preview.pdf +0 -0
- data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/QuickLook/Thumbnail.tiff +0 -0
- data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/data.plist +0 -0
- data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/image10.png +0 -0
- data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/image11.png +0 -0
- data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/image13.png +0 -0
- data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/image15.png +0 -0
- data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/image16.png +0 -0
- data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/image17.png +0 -0
- data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/image18.png +0 -0
- data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/image19.png +0 -0
- data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/image22.tiff +0 -0
- data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/image23.png +0 -0
- data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/image24.png +0 -0
- data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/image25.png +0 -0
- data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/image30.png +0 -0
- data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/image31.png +0 -0
- data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/image8.png +0 -0
- data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/image9.png +0 -0
- data/lib/frameworks/sproutcore/frameworks/animation/core.js +23 -25
- data/lib/frameworks/sproutcore/frameworks/bootstrap/system/browser.js +160 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/controllers/array.js +73 -82
- data/lib/frameworks/sproutcore/frameworks/core_foundation/core.js +1 -3
- data/lib/frameworks/sproutcore/frameworks/{handlebars/extensions → core_foundation/ext/handlebars}/bind.js +110 -7
- data/lib/frameworks/sproutcore/frameworks/{handlebars/extensions → core_foundation/ext/handlebars}/collection.js +10 -7
- data/lib/frameworks/sproutcore/frameworks/{handlebars/extensions → core_foundation/ext/handlebars}/localization.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/{handlebars/extensions → core_foundation/ext/handlebars}/view.js +4 -2
- data/lib/frameworks/sproutcore/frameworks/{handlebars/extensions.js → core_foundation/ext/handlebars.js} +0 -57
- data/lib/frameworks/sproutcore/frameworks/core_foundation/ext/object.js +1 -3
- data/lib/frameworks/sproutcore/frameworks/core_foundation/mixins/template_helpers/text_field_support.js +11 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/main.js +1 -3
- data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/pane.js +2 -4
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/application.js +14 -16
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/builder.js +29 -37
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/datetime.js +0 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/event.js +71 -19
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/locale.js +3 -7
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/page.js +5 -7
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/selection_set.js +1 -3
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/sparse_array.js +4 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/timer.js +21 -27
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/utils.js +3 -5
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/controllers/array/array_case.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/controllers/object/single_enumerable_case.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/sparse_array.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/template/handlebars.js +93 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/clippingFrame.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/convertLayouts.js +13 -11
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layer.js +2 -6
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layoutStyle.js +4 -4
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/theme.js +2 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/view.js +4 -4
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/template.js +6 -2
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/template_collection.js +87 -32
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/layout.js +21 -25
- data/lib/frameworks/sproutcore/frameworks/datastore/data_sources/cascade.js +15 -19
- data/lib/frameworks/sproutcore/frameworks/datastore/data_sources/data_source.js +114 -167
- data/lib/frameworks/sproutcore/frameworks/datastore/data_sources/fixtures.js +4 -4
- data/lib/frameworks/sproutcore/frameworks/datastore/models/child_attribute.js +4 -6
- data/lib/frameworks/sproutcore/frameworks/datastore/models/children_attribute.js +2 -4
- data/lib/frameworks/sproutcore/frameworks/datastore/models/fetched_attribute.js +7 -7
- data/lib/frameworks/sproutcore/frameworks/datastore/models/many_attribute.js +18 -20
- data/lib/frameworks/sproutcore/frameworks/datastore/models/record.js +74 -72
- data/lib/frameworks/sproutcore/frameworks/datastore/models/record_attribute.js +36 -29
- data/lib/frameworks/sproutcore/frameworks/datastore/models/single_attribute.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/datastore/system/child_array.js +97 -78
- data/lib/frameworks/sproutcore/frameworks/datastore/system/many_array.js +117 -97
- data/lib/frameworks/sproutcore/frameworks/datastore/system/nested_store.js +13 -13
- data/lib/frameworks/sproutcore/frameworks/datastore/system/query.js +111 -108
- data/lib/frameworks/sproutcore/frameworks/datastore/system/record_array.js +231 -198
- data/lib/frameworks/sproutcore/frameworks/datastore/system/store.js +146 -145
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/query/builders.js +21 -21
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/record_array/flush.js +49 -50
- data/lib/frameworks/sproutcore/frameworks/datetime/{system → frameworks/core/system}/datetime.js +122 -171
- data/lib/frameworks/sproutcore/frameworks/datetime/{tests → frameworks/core/tests}/system/datetime.js +0 -0
- data/lib/frameworks/sproutcore/frameworks/datetime/{resources → frameworks/localized/resources}/strings.js +0 -0
- data/lib/frameworks/sproutcore/frameworks/datetime/frameworks/localized/system/datetime.js +91 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/core.js +18 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/mixins/border.js +23 -16
- data/lib/frameworks/sproutcore/frameworks/desktop/mixins/collection_fast_path.js +56 -45
- data/lib/frameworks/sproutcore/frameworks/desktop/mixins/collection_group.js +5 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/mixins/collection_row_delegate.js +21 -19
- data/lib/frameworks/sproutcore/frameworks/desktop/mixins/collection_view_delegate.js +82 -77
- data/lib/frameworks/sproutcore/frameworks/desktop/mixins/navigation_builder.js +18 -12
- data/lib/frameworks/sproutcore/frameworks/desktop/mixins/scrollable.js +29 -17
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/alert.js +148 -107
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/menu.js +31 -16
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/modal.js +16 -13
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/palette.js +38 -17
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/panel.js +37 -25
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/picker.js +247 -144
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/select_button.js +155 -100
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/sheet.js +39 -17
- data/lib/frameworks/sproutcore/frameworks/desktop/protocols/drag_data_source.js +9 -6
- data/lib/frameworks/sproutcore/frameworks/desktop/protocols/drag_source.js +18 -22
- data/lib/frameworks/sproutcore/frameworks/desktop/protocols/drop_target.js +27 -17
- data/lib/frameworks/sproutcore/frameworks/desktop/system/drag.js +77 -44
- data/lib/frameworks/sproutcore/frameworks/desktop/system/undo_manager.js +68 -33
- data/lib/frameworks/sproutcore/frameworks/desktop/views/button.js +168 -110
- data/lib/frameworks/sproutcore/frameworks/desktop/views/checkbox.js +37 -5
- data/lib/frameworks/sproutcore/frameworks/desktop/views/collection.js +187 -123
- data/lib/frameworks/sproutcore/frameworks/desktop/views/date_field.js +73 -49
- data/lib/frameworks/sproutcore/frameworks/desktop/views/disclosure.js +34 -9
- data/lib/frameworks/sproutcore/frameworks/desktop/views/file.js +51 -14
- data/lib/frameworks/sproutcore/frameworks/desktop/views/grid.js +38 -8
- data/lib/frameworks/sproutcore/frameworks/desktop/views/image_button.js +15 -9
- data/lib/frameworks/sproutcore/frameworks/desktop/views/list.js +54 -34
- data/lib/frameworks/sproutcore/frameworks/desktop/views/list_item.js +113 -42
- data/lib/frameworks/sproutcore/frameworks/desktop/views/master_detail.js +84 -28
- data/lib/frameworks/sproutcore/frameworks/desktop/views/menu_item.js +67 -51
- data/lib/frameworks/sproutcore/frameworks/desktop/views/menu_scroll.js +122 -35
- data/lib/frameworks/sproutcore/frameworks/desktop/views/navigation.js +40 -16
- data/lib/frameworks/sproutcore/frameworks/desktop/views/navigation_bar.js +28 -18
- data/lib/frameworks/sproutcore/frameworks/desktop/views/popup_button.js +27 -31
- data/lib/frameworks/sproutcore/frameworks/desktop/views/progress.js +118 -68
- data/lib/frameworks/sproutcore/frameworks/desktop/views/radio.js +117 -61
- data/lib/frameworks/sproutcore/frameworks/desktop/views/scene.js +23 -16
- data/lib/frameworks/sproutcore/frameworks/desktop/views/scroll.js +241 -77
- data/lib/frameworks/sproutcore/frameworks/desktop/views/scroller.js +134 -69
- data/lib/frameworks/sproutcore/frameworks/desktop/views/segment.js +107 -25
- data/lib/frameworks/sproutcore/frameworks/desktop/views/segmented.js +125 -48
- data/lib/frameworks/sproutcore/frameworks/desktop/views/select.js +165 -69
- data/lib/frameworks/sproutcore/frameworks/desktop/views/select_field.js +73 -24
- data/lib/frameworks/sproutcore/frameworks/desktop/views/separator.js +19 -5
- data/lib/frameworks/sproutcore/frameworks/desktop/views/source_list.js +16 -4
- data/lib/frameworks/sproutcore/frameworks/desktop/views/source_list_group.js +14 -7
- data/lib/frameworks/sproutcore/frameworks/desktop/views/split.js +43 -37
- data/lib/frameworks/sproutcore/frameworks/desktop/views/split_divider.js +8 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/views/stacked.js +14 -3
- data/lib/frameworks/sproutcore/frameworks/desktop/views/static_content.js +16 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/views/tab.js +99 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/views/thumb.js +13 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/views/toolbar.js +58 -8
- data/lib/frameworks/sproutcore/frameworks/desktop/views/web.js +34 -18
- data/lib/frameworks/sproutcore/frameworks/desktop/views/well.js +25 -9
- data/lib/frameworks/sproutcore/frameworks/desktop/views/workspace.js +70 -36
- data/lib/frameworks/sproutcore/frameworks/foundation/controllers/tree.js +10 -5
- data/lib/frameworks/sproutcore/frameworks/foundation/debug/control_test_pane.js +28 -17
- data/lib/frameworks/sproutcore/frameworks/foundation/delegates/inline_text_field.js +41 -43
- data/lib/frameworks/sproutcore/frameworks/foundation/gestures/pinch.js +42 -4
- data/lib/frameworks/sproutcore/frameworks/foundation/gestures/swipe.js +94 -4
- data/lib/frameworks/sproutcore/frameworks/foundation/gestures/tap.js +41 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/auto_mixin.js +2 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/auto_resize.js +18 -9
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/collection_content.js +7 -5
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/content_display.js +7 -8
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/content_value_support.js +34 -24
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/control.js +48 -18
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/inline_text_field.js +1 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/system/utils/misc.js +1 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/tasks/preload_bundle.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/inline_text_field/beginEditing.js +0 -11
- data/lib/frameworks/sproutcore/frameworks/foundation/validators/date_time.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/views/text_field.js +8 -0
- data/lib/frameworks/sproutcore/frameworks/qunit/README.md +24 -0
- data/lib/frameworks/sproutcore/frameworks/qunit/package.json +21 -0
- data/lib/frameworks/sproutcore/frameworks/qunit/qunit/qunit.css +215 -0
- data/lib/frameworks/sproutcore/frameworks/qunit/qunit/qunit.js +1442 -0
- data/lib/frameworks/sproutcore/frameworks/qunit/test/headless.html +24 -0
- data/lib/frameworks/sproutcore/frameworks/qunit/test/index.html +18 -0
- data/lib/frameworks/sproutcore/frameworks/qunit/test/logs.html +17 -0
- data/lib/frameworks/sproutcore/frameworks/qunit/test/logs.js +150 -0
- data/lib/frameworks/sproutcore/frameworks/qunit/test/same.js +1421 -0
- data/lib/frameworks/sproutcore/frameworks/qunit/test/test.js +314 -0
- data/lib/frameworks/sproutcore/frameworks/runtime/core.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/mixins/array.js +369 -60
- data/lib/frameworks/sproutcore/frameworks/runtime/mixins/enumerable.js +2 -405
- data/lib/frameworks/sproutcore/frameworks/runtime/mixins/observable.js +3 -9
- data/lib/frameworks/sproutcore/frameworks/runtime/private/property_chain.js +50 -45
- data/lib/frameworks/sproutcore/frameworks/runtime/system/binding.js +20 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/system/object.js +0 -9
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/core/guidFor.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/array.js +36 -14
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/enumerable/enumerable.js +0 -34
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/enumerable/enumerable_observers.js +50 -61
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/observable/observable.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/observable/propertyChanges.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/observable/registerDependentKeys.js +45 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/propertyChanges.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/object/bindings.js +5 -0
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/object/enhance.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/testing/core.js +3 -0
- data/lib/frameworks/sproutcore/frameworks/testing/system/plan.js +0 -1
- data/lib/frameworks/sproutcore/frameworks/testing/system/runner.js +0 -1
- data/lib/gen/html_app/templates/apps/@target_name@/@target_name@.js +1 -1
- data/vendor/chance/lib/chance/instance.rb +8 -6
- metadata +41 -31
- data/lib/frameworks/sproutcore/frameworks/testing/jquery.js +0 -3559
- data/lib/frameworks/sproutcore/frameworks/testing/qunit.js +0 -827
@@ -14,43 +14,43 @@ sc_require('models/record');
|
|
14
14
|
This permits you to perform queries on your data store,
|
15
15
|
written in a SQL-like language. Here is a simple example:
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
q = SC.Query.create({
|
18
|
+
conditions: "firstName = 'Jonny' AND lastName = 'Cash'"
|
19
|
+
})
|
20
20
|
|
21
|
-
You can check if a certain record matches the query by calling
|
21
|
+
You can check if a certain record matches the query by calling
|
22
22
|
|
23
|
-
|
23
|
+
q.contains(record)
|
24
24
|
|
25
25
|
To find all records of your store, that match query q, use findAll with
|
26
26
|
query q as argument:
|
27
27
|
|
28
|
-
|
28
|
+
r = MyApp.store.findAll(q)
|
29
29
|
|
30
|
-
r will be a record array containing all matching records.
|
31
|
-
To limit the query to a record type of MyApp.MyModel
|
30
|
+
`r` will be a record array containing all matching records.
|
31
|
+
To limit the query to a record type of `MyApp.MyModel`,
|
32
32
|
you can specify the type as a property of the query like this:
|
33
33
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
34
|
+
q = SC.Query.create({
|
35
|
+
conditions: "firstName = 'Jonny' AND lastName = 'Cash'",
|
36
|
+
recordType: MyApp.MyModel
|
37
|
+
})
|
38
38
|
|
39
|
-
Calling find() like above will now return only records of type t.
|
39
|
+
Calling `find()` like above will now return only records of type t.
|
40
40
|
It is recommended to limit your query to a record type, since the query will
|
41
41
|
have to look for matching records in the whole store, if no record type
|
42
42
|
is given.
|
43
43
|
|
44
44
|
You can give an order, which the resulting records should follow, like this:
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
46
|
+
q = SC.Query.create({
|
47
|
+
conditions: "firstName = 'Jonny' AND lastName = 'Cash'",
|
48
|
+
recordType: MyApp.MyModel,
|
49
|
+
orderBy: "lastName, year DESC"
|
50
|
+
});
|
51
51
|
|
52
52
|
The default order direction is ascending. You can change it to descending
|
53
|
-
by writing DESC behind the property name like in the example above.
|
53
|
+
by writing `'DESC'` behind the property name like in the example above.
|
54
54
|
If no order is given, or records are equal in respect to a given order,
|
55
55
|
records will be ordered by guid.
|
56
56
|
|
@@ -61,60 +61,61 @@ sc_require('models/record');
|
|
61
61
|
|
62
62
|
Primitives:
|
63
63
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
64
|
+
- record properties
|
65
|
+
- `null`, `undefined`
|
66
|
+
- `true`, `false`
|
67
|
+
- numbers (integers and floats)
|
68
|
+
- strings (double or single quoted)
|
69
69
|
|
70
70
|
Parameters:
|
71
71
|
|
72
|
-
|
73
|
-
|
72
|
+
- `%@` (wild card)
|
73
|
+
- `{parameterName}` (named parameter)
|
74
74
|
|
75
75
|
Wild cards are used to identify parameters by the order in which they appear
|
76
76
|
in the query string. Named parameters can be used when tracking the order
|
77
77
|
becomes difficult. Both types of parameters can be used by giving the
|
78
78
|
parameters as a property to your query object:
|
79
79
|
|
80
|
-
|
80
|
+
yourQuery.parameters = yourParameters
|
81
81
|
|
82
82
|
where yourParameters should have one of the following formats:
|
83
83
|
|
84
|
-
|
85
|
-
|
84
|
+
* for wild cards: `[firstParam, secondParam, thirdParam]`
|
85
|
+
* for named params: `{name1: param1, mane2: parma2}`
|
86
86
|
|
87
87
|
You cannot use both types of parameters in a single query!
|
88
88
|
|
89
89
|
Operators:
|
90
90
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
91
|
+
- `=`
|
92
|
+
- `!=`
|
93
|
+
- `<`
|
94
|
+
- `<=`
|
95
|
+
- `>`
|
96
|
+
- `>=`
|
97
|
+
- `BEGINS_WITH` -- (checks if a string starts with another one)
|
98
|
+
- `ENDS_WITH` -- (checks if a string ends with another one)
|
99
|
+
- `CONTAINS` -- (checks if a string contains another one, or if an
|
100
|
+
object is in an array)
|
101
|
+
- `MATCHES` -- (checks if a string is matched by a regexp,
|
102
|
+
you will have to use a parameter to insert the regexp)
|
103
|
+
- `ANY` -- (checks if the thing on its left is contained in the array
|
104
|
+
on its right, you will have to use a parameter
|
105
|
+
to insert the array)
|
106
|
+
- `TYPE_IS` -- (unary operator expecting a string containing the name
|
107
|
+
of a Model class on its right side, only records of this
|
108
|
+
type will match)
|
108
109
|
|
109
110
|
Boolean Operators:
|
110
111
|
|
111
|
-
|
112
|
-
|
113
|
-
|
112
|
+
- `AND`
|
113
|
+
- `OR`
|
114
|
+
- `NOT`
|
114
115
|
|
115
116
|
Parenthesis for grouping:
|
116
117
|
|
117
|
-
|
118
|
+
- `(` and `)`
|
118
119
|
|
119
120
|
|
120
121
|
Adding Your Own Query Handlers
|
@@ -122,12 +123,12 @@ sc_require('models/record');
|
|
122
123
|
|
123
124
|
You can extend the query language with your own operators by calling:
|
124
125
|
|
125
|
-
|
126
|
+
SC.Query.registerQueryExtension('your_operator', your_operator_definition);
|
126
127
|
|
127
128
|
See details below. As well you can provide your own comparison functions
|
128
129
|
to control ordering of specific record properties like this:
|
129
130
|
|
130
|
-
|
131
|
+
SC.Query.registerComparison(property_name, comparison_for_this_property);
|
131
132
|
|
132
133
|
Examples
|
133
134
|
|
@@ -165,7 +166,7 @@ SC.Query = SC.Object.extend(SC.Copyable, SC.Freezable,
|
|
165
166
|
|
166
167
|
/**
|
167
168
|
Optional orderBy parameters. This can be a string of keys, optionally
|
168
|
-
beginning with the strings "DESC " or "ASC " to select descending or
|
169
|
+
beginning with the strings `"DESC "` or `"ASC "` to select descending or
|
169
170
|
ascending order.
|
170
171
|
|
171
172
|
Alternatively, you can specify a comparison function, in which case the
|
@@ -194,8 +195,8 @@ SC.Query = SC.Object.extend(SC.Copyable, SC.Freezable,
|
|
194
195
|
recordTypes: null,
|
195
196
|
|
196
197
|
/**
|
197
|
-
Returns the complete set of
|
198
|
-
any named
|
198
|
+
Returns the complete set of `recordType`s matched by this query. Includes
|
199
|
+
any named `recordType`s plus their subclasses.
|
199
200
|
|
200
201
|
@property
|
201
202
|
@type SC.Enumerable
|
@@ -247,20 +248,22 @@ SC.Query = SC.Object.extend(SC.Copyable, SC.Freezable,
|
|
247
248
|
Indicates the location where the result set for this query is stored.
|
248
249
|
Currently the available options are:
|
249
250
|
|
250
|
-
|
251
|
-
|
251
|
+
- `SC.Query.LOCAL` -- indicates that the query results will be
|
252
|
+
automatically computed from the in-memory store.
|
253
|
+
- `SC.Query.REMOTE` -- indicates that the query results are kept on a
|
254
|
+
remote server and hence must be loaded from the `DataSource`.
|
252
255
|
|
253
|
-
The default setting for this property is SC.Query.LOCAL
|
256
|
+
The default setting for this property is `SC.Query.LOCAL`.
|
254
257
|
|
255
|
-
Note that even if a query location is LOCAL
|
256
|
-
have its fetch() method called for the query. For LOCAL
|
257
|
-
won't need to explicitly provide the query result set; you
|
258
|
-
records into the in-memory store as needed and let the query
|
259
|
-
automatically.
|
258
|
+
Note that even if a query location is `LOCAL`, your `DataSource` will
|
259
|
+
still have its `fetch()` method called for the query. For `LOCAL`
|
260
|
+
queries, you won't need to explicitly provide the query result set; you
|
261
|
+
can just load records into the in-memory store as needed and let the query
|
262
|
+
recompute automatically.
|
260
263
|
|
261
|
-
If your query location is REMOTE
|
264
|
+
If your query location is `REMOTE`, then your `DataSource` will need to
|
262
265
|
provide the actual set of query results manually. Usually you will only
|
263
|
-
need to use a REMOTE query if you are retrieving a large data set and you
|
266
|
+
need to use a `REMOTE` query if you are retrieving a large data set and you
|
264
267
|
don't want to pay the cost of computing the result set client side.
|
265
268
|
|
266
269
|
@type String
|
@@ -269,7 +272,7 @@ SC.Query = SC.Object.extend(SC.Copyable, SC.Freezable,
|
|
269
272
|
|
270
273
|
/**
|
271
274
|
Another query that will optionally limit the search of records. This is
|
272
|
-
usually configured for you when you do find() from another record array.
|
275
|
+
usually configured for you when you do `find()` from another record array.
|
273
276
|
|
274
277
|
@type SC.Query
|
275
278
|
*/
|
@@ -277,7 +280,7 @@ SC.Query = SC.Object.extend(SC.Copyable, SC.Freezable,
|
|
277
280
|
|
278
281
|
|
279
282
|
/**
|
280
|
-
Returns YES if query location is Remote. This is sometimes more
|
283
|
+
Returns `YES` if query location is Remote. This is sometimes more
|
281
284
|
convenient than checking the location.
|
282
285
|
|
283
286
|
@property
|
@@ -288,7 +291,7 @@ SC.Query = SC.Object.extend(SC.Copyable, SC.Freezable,
|
|
288
291
|
}.property('location').cacheable(),
|
289
292
|
|
290
293
|
/**
|
291
|
-
Returns YES if query location is Local. This is sometimes more
|
294
|
+
Returns `YES` if query location is Local. This is sometimes more
|
292
295
|
convenient than checking the location.
|
293
296
|
|
294
297
|
@property
|
@@ -299,7 +302,7 @@ SC.Query = SC.Object.extend(SC.Copyable, SC.Freezable,
|
|
299
302
|
}.property('location').cacheable(),
|
300
303
|
|
301
304
|
/**
|
302
|
-
Indicates whether a record is editable or not. Defaults to NO
|
305
|
+
Indicates whether a record is editable or not. Defaults to `NO`. Local
|
303
306
|
queries should never be made editable. Remote queries may be editable or
|
304
307
|
not depending on the data source.
|
305
308
|
*/
|
@@ -310,7 +313,7 @@ SC.Query = SC.Object.extend(SC.Copyable, SC.Freezable,
|
|
310
313
|
//
|
311
314
|
|
312
315
|
/**
|
313
|
-
Returns YES if record is matched by the query, NO otherwise. This is
|
316
|
+
Returns `YES` if record is matched by the query, `NO` otherwise. This is
|
314
317
|
used when computing a query locally.
|
315
318
|
|
316
319
|
@param {SC.Record} record the record to check
|
@@ -344,7 +347,7 @@ SC.Query = SC.Object.extend(SC.Copyable, SC.Freezable,
|
|
344
347
|
},
|
345
348
|
|
346
349
|
/**
|
347
|
-
Returns YES if the query matches one or more of the record types in the
|
350
|
+
Returns `YES` if the query matches one or more of the record types in the
|
348
351
|
passed set.
|
349
352
|
|
350
353
|
@param {SC.Set} types set of record types
|
@@ -367,7 +370,7 @@ SC.Query = SC.Object.extend(SC.Copyable, SC.Freezable,
|
|
367
370
|
Returns the sort order of the two passed records, taking into account the
|
368
371
|
orderBy property set on this query. This method does not verify that the
|
369
372
|
two records actually belong in the query set or not; this is checked using
|
370
|
-
contains()
|
373
|
+
`contains()`.
|
371
374
|
|
372
375
|
@param {SC.Record} record1 the first record
|
373
376
|
@param {SC.Record} record2 the second record
|
@@ -434,9 +437,9 @@ SC.Query = SC.Object.extend(SC.Copyable, SC.Freezable,
|
|
434
437
|
|
435
438
|
/**
|
436
439
|
This method has to be called before the query object can be used.
|
437
|
-
You will normaly not have to do this
|
440
|
+
You will normaly not have to do this; it will be called automatically
|
438
441
|
if you try to evaluate a query.
|
439
|
-
You can however use this function for testing your queries.
|
442
|
+
You can, however, use this function for testing your queries.
|
440
443
|
|
441
444
|
@returns {Boolean} true if parsing succeeded, false otherwise
|
442
445
|
*/
|
@@ -516,7 +519,7 @@ SC.Query = SC.Object.extend(SC.Copyable, SC.Freezable,
|
|
516
519
|
|
517
520
|
/**
|
518
521
|
This is the definition of the query language. You can extend it
|
519
|
-
by using SC.Query.registerQueryExtension()
|
522
|
+
by using `SC.Query.registerQueryExtension()`.
|
520
523
|
*/
|
521
524
|
queryLanguage: {
|
522
525
|
|
@@ -867,7 +870,7 @@ SC.Query = SC.Object.extend(SC.Copyable, SC.Freezable,
|
|
867
870
|
|
868
871
|
/**
|
869
872
|
Takes a string and tokenizes it based on the grammar definition
|
870
|
-
provided. Called by parse()
|
873
|
+
provided. Called by `parse()`.
|
871
874
|
|
872
875
|
@param {String} inputString the string to tokenize
|
873
876
|
@param {Object} grammar the grammar definition (normally queryLanguage)
|
@@ -1015,11 +1018,11 @@ SC.Query = SC.Object.extend(SC.Copyable, SC.Freezable,
|
|
1015
1018
|
specified tree logic. The returned object will have an error property
|
1016
1019
|
if building of the tree failed. Check it to get some information
|
1017
1020
|
about what happend.
|
1018
|
-
If everything worked the tree can be evaluated by calling
|
1021
|
+
If everything worked, the tree can be evaluated by calling
|
1019
1022
|
|
1020
|
-
|
1023
|
+
tree.evaluate(record, parameters)
|
1021
1024
|
|
1022
|
-
If tokenList is empty, a single token will be returned which will
|
1025
|
+
If `tokenList` is empty, a single token will be returned which will
|
1023
1026
|
evaluate to true for all records.
|
1024
1027
|
|
1025
1028
|
@param {Array} tokenList the list of tokens
|
@@ -1180,7 +1183,7 @@ SC.Query = SC.Object.extend(SC.Copyable, SC.Freezable,
|
|
1180
1183
|
/**
|
1181
1184
|
Takes a string containing an order statement and returns an array
|
1182
1185
|
describing this order for easier processing.
|
1183
|
-
Called by parse()
|
1186
|
+
Called by `parse()`.
|
1184
1187
|
|
1185
1188
|
@param {String | Function} orderOp the string containing the order statement, or a comparison function
|
1186
1189
|
@returns {Array | Function} array of order statement, or a function if a function was specified
|
@@ -1215,22 +1218,22 @@ SC.Query = SC.Object.extend(SC.Copyable, SC.Freezable,
|
|
1215
1218
|
SC.Query.mixin( /** @scope SC.Query */ {
|
1216
1219
|
|
1217
1220
|
/**
|
1218
|
-
Constant used for SC.Query#location
|
1221
|
+
Constant used for `SC.Query#location`
|
1219
1222
|
|
1220
1223
|
@type String
|
1221
1224
|
*/
|
1222
1225
|
LOCAL: 'local',
|
1223
1226
|
|
1224
1227
|
/**
|
1225
|
-
Constant used for SC.Query#location
|
1228
|
+
Constant used for `SC.Query#location`
|
1226
1229
|
|
1227
1230
|
@type String
|
1228
1231
|
*/
|
1229
1232
|
REMOTE: 'remote',
|
1230
1233
|
|
1231
1234
|
/**
|
1232
|
-
Given a query, returns the associated storeKey
|
1233
|
-
method see SC.Store.queryFor()
|
1235
|
+
Given a query, returns the associated `storeKey`. For the inverse of this
|
1236
|
+
method see `SC.Store.queryFor()`.
|
1234
1237
|
|
1235
1238
|
@param {SC.Query} query the query
|
1236
1239
|
@returns {Number} a storeKey.
|
@@ -1240,7 +1243,7 @@ SC.Query.mixin( /** @scope SC.Query */ {
|
|
1240
1243
|
},
|
1241
1244
|
|
1242
1245
|
/**
|
1243
|
-
Will find which records match a give SC.Query and return an array of
|
1246
|
+
Will find which records match a give `SC.Query` and return an array of
|
1244
1247
|
store keys. This will also apply the sorting for the query.
|
1245
1248
|
|
1246
1249
|
@param {SC.Query} query to apply
|
@@ -1264,7 +1267,7 @@ SC.Query.mixin( /** @scope SC.Query */ {
|
|
1264
1267
|
|
1265
1268
|
/**
|
1266
1269
|
Sorts a set of store keys according to the orderBy property
|
1267
|
-
of the SC.Query
|
1270
|
+
of the `SC.Query`.
|
1268
1271
|
|
1269
1272
|
@param {Array} storeKeys to sort
|
1270
1273
|
@param {SC.Query} query to use for sorting
|
@@ -1298,9 +1301,9 @@ SC.Query.mixin( /** @scope SC.Query */ {
|
|
1298
1301
|
},
|
1299
1302
|
|
1300
1303
|
/**
|
1301
|
-
Default sort method that is used when calling containsStoreKeys()
|
1302
|
-
or containsRecords() on this query. Simply materializes two records
|
1303
|
-
on
|
1304
|
+
Default sort method that is used when calling `containsStoreKeys()`
|
1305
|
+
or `containsRecords()` on this query. Simply materializes two records
|
1306
|
+
based on `storekey`s before passing on to `compare()`.
|
1304
1307
|
|
1305
1308
|
@param {Number} storeKey1 a store key
|
1306
1309
|
@param {Number} storeKey2 a store key
|
@@ -1374,14 +1377,14 @@ SC.Query.mixin( /** @scope SC.Query */ {
|
|
1374
1377
|
},
|
1375
1378
|
|
1376
1379
|
/**
|
1377
|
-
Returns a SC.Query instance reflecting the passed properties. Where
|
1380
|
+
Returns a `SC.Query` instance reflecting the passed properties. Where
|
1378
1381
|
possible this method will return cached query instances so that multiple
|
1379
1382
|
calls to this method will return the same instance. This is not possible
|
1380
1383
|
however, when you pass custom parameters or set ordering. All returned
|
1381
1384
|
queries are frozen.
|
1382
1385
|
|
1383
1386
|
Usually you will not call this method directly. Instead use the more
|
1384
|
-
convenient SC.Query.local() and SC.Query.remote()
|
1387
|
+
convenient `SC.Query.local()` and `SC.Query.remote()`.
|
1385
1388
|
|
1386
1389
|
Examples
|
1387
1390
|
|
@@ -1390,26 +1393,26 @@ SC.Query.mixin( /** @scope SC.Query */ {
|
|
1390
1393
|
The following return local queries selecting all records of a particular
|
1391
1394
|
type or types, including any subclasses:
|
1392
1395
|
|
1393
|
-
|
1394
|
-
|
1396
|
+
var people = SC.Query.local(Ab.Person);
|
1397
|
+
var peopleAndCompanies = SC.Query.local([Ab.Person, Ab.Company]);
|
1395
1398
|
|
1396
|
-
|
1397
|
-
|
1399
|
+
var people = SC.Query.local('Ab.Person');
|
1400
|
+
var peopleAndCompanies = SC.Query.local('Ab.Person Ab.Company'.w());
|
1398
1401
|
|
1399
|
-
|
1402
|
+
var allRecords = SC.Query.local(SC.Record);
|
1400
1403
|
|
1401
1404
|
The following will match a particular type of condition:
|
1402
1405
|
|
1403
|
-
|
1404
|
-
|
1405
|
-
|
1406
|
-
|
1407
|
-
|
1406
|
+
var married = SC.Query.local(Ab.Person, "isMarried=YES");
|
1407
|
+
var married = SC.Query.local(Ab.Person, "isMarried=%@", [YES]);
|
1408
|
+
var married = SC.Query.local(Ab.Person, "isMarried={married}", {
|
1409
|
+
married: YES
|
1410
|
+
});
|
1408
1411
|
|
1409
1412
|
You can also pass a hash of options as the second parameter. This is
|
1410
1413
|
how you specify an order, for example:
|
1411
1414
|
|
1412
|
-
|
1415
|
+
var orderedPeople = SC.Query.local(Ab.Person, { orderBy: "firstName" });
|
1413
1416
|
|
1414
1417
|
@param {String} location the query location.
|
1415
1418
|
@param {SC.Record|Array} recordType the record type or types.
|
@@ -1499,8 +1502,8 @@ SC.Query.mixin( /** @scope SC.Query */ {
|
|
1499
1502
|
},
|
1500
1503
|
|
1501
1504
|
/**
|
1502
|
-
Returns a LOCAL query with the passed options. For a full description of
|
1503
|
-
the parameters you can pass to this method, see SC.Query.build()
|
1505
|
+
Returns a `LOCAL` query with the passed options. For a full description of
|
1506
|
+
the parameters you can pass to this method, see `SC.Query.build()`.
|
1504
1507
|
|
1505
1508
|
@param {SC.Record|Array} recordType the record type or types.
|
1506
1509
|
@param {String} conditions optional conditions
|
@@ -1512,8 +1515,8 @@ SC.Query.mixin( /** @scope SC.Query */ {
|
|
1512
1515
|
},
|
1513
1516
|
|
1514
1517
|
/**
|
1515
|
-
Returns a REMOTE query with the passed options. For a full description of
|
1516
|
-
the parameters you can pass to this method, see SC.Query.build()
|
1518
|
+
Returns a `REMOTE` query with the passed options. For a full description of
|
1519
|
+
the parameters you can pass to this method, see `SC.Query.build()`.
|
1517
1520
|
|
1518
1521
|
@param {SC.Record|Array} recordType the record type or types.
|
1519
1522
|
@param {String} conditions optional conditions
|
@@ -1525,7 +1528,7 @@ SC.Query.mixin( /** @scope SC.Query */ {
|
|
1525
1528
|
},
|
1526
1529
|
|
1527
1530
|
/** @private
|
1528
|
-
called by SC.Record.extend()
|
1531
|
+
called by `SC.Record.extend()`. invalidates `expandedRecordTypes`
|
1529
1532
|
*/
|
1530
1533
|
_scq_didDefineRecordType: function() {
|
1531
1534
|
var q = SC.Query._scq_queriesWithExpandedRecordTypes;
|
@@ -1565,7 +1568,7 @@ SC.Query.registerComparison = function(propertyName, comparison) {
|
|
1565
1568
|
You shoud provide a name for your extension and a definition
|
1566
1569
|
specifying how it should be parsed and evaluated.
|
1567
1570
|
|
1568
|
-
Have a look at queryLanguage for examples of definitions.
|
1571
|
+
Have a look at `queryLanguage` for examples of definitions.
|
1569
1572
|
|
1570
1573
|
TODO add better documentation here
|
1571
1574
|
|