File tree Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -82,6 +82,25 @@ Indexes can be scoped to a specific database:
8282 index({ ssn: 1 }, { database: "users", unique: true, background: true })
8383 end
8484
85+ You may use aliased field names in index definitions. Field aliases
86+ will also be resolved on the following options: ``partial_filter_expression``,
87+ ``weights``, ``wildcard_projection``.
88+
89+ .. code-block:: ruby
90+
91+ class Person
92+ include Mongoid::Document
93+ field :a, as: :age
94+ index({ age: 1 }, { partial_filter_expression: { age: { '$gte' => 20 } })
95+ end
96+
97+ .. note::
98+
99+ The expansion of field name aliases in index options such as
100+ ``partial_filter_expression`` is performed according to the behavior of MongoDB
101+ server 6.0. Future server versions may change how they interpret these options,
102+ and Mongoid's functionality may not support such changes.
103+
85104Mongoid can define indexes on "foreign key" fields for associations.
86105This only works on the association macro that the foreign key is stored on:
87106
Original file line number Diff line number Diff line change @@ -241,6 +241,29 @@ defaults to ``true``.
241241When set to false, the older, inconsistent behavior is restored.
242242
243243
244+ Support Field Aliases on Index Options
245+ --------------------------------------
246+
247+ Support has been added to use aliased field names in the following options
248+ of the ``index`` macro: ``partial_filter_expression``, ``weights``,
249+ ``wildcard_projection``.
250+
251+ .. code-block:: ruby
252+
253+ class Person
254+ include Mongoid::Document
255+ field :a, as: :age
256+ index({ age: 1 }, { partial_filter_expression: { age: { '$gte' => 20 } })
257+ end
258+
259+ .. note::
260+
261+ The expansion of field name aliases in index options such as
262+ ``partial_filter_expression`` is performed according to the behavior of MongoDB
263+ server 6.0. Future server versions may change how they interpret these options,
264+ and Mongoid's functionality may not support such changes.
265+
266+
244267Bug Fixes and Improvements
245268--------------------------
246269
You can’t perform that action at this time.
0 commit comments