@@ -141,35 +141,33 @@ Note that all this eager related options are optional.
141141
142142- ** ` allowedEager ` ** - relation expression to limit the allowed eager queries in
143143 the service. Defaults to ` '[]' ` , meaning no eager queries allowed. See
144- [ ` allowEager ` ] ( https://vincit.github.io/objection.js/api/query-builder/eager-methods.html#alloweager )
144+ [ ` allowGraph ` ] ( https://vincit.github.io/objection.js/api/query-builder/eager-methods.html#allowgraph )
145145 documentation.
146146- ** ` eagerFilters ` ** - option to impose compulsory eager filter. It takes an
147147 object or array of objects with the following properties:
148148 - ` expression ` - the relation expression that the filter will be applied.
149149 - ` filter ` - the filter function. It uses
150- [ ` modifyEager ` ] ( https://vincit.github.io/objection.js/api/query-builder/eager-methods.html#modifyeager )
150+ [ ` modifyGraph ` ] ( https://vincit.github.io/objection.js/api/query-builder/eager-methods.html#modifygraph )
151151 internally.
152- - ** ` namedEagerFilters ` ** - object containing named eager filter functions.
153- Filter is opt-in via ` $eager ` parameter.
154152
155153#### Query Operators
156154
157- - ** ` $eager ` ** - eager load relations defined in models'
158- ` relationMappings ` getter methods or in the ` namedEagerFilters ` option. See
159- [ ` eager ` ] ( https://vincit.github.io/objection.js/api/query-builder/eager-methods.html#eager ) documentation.
160- - ** ` $joinRelation ` ** - filter based on a relation's field. See
161- [ ` joinRelation ` ] ( https://vincit.github.io/objection.js/api/query-builder/join-methods.html#joinrelation )
155+ - ** ` $eager ` ** - eager load relations defined in models' ` relationMappings ` getter methods. See
156+ [ ` withGraphFetched ` ] ( https://vincit.github.io/objection.js/api/query-builder/eager- methods.html#withgraphfetched ) documentation.
157+
158+ - ** ` $joinRelation ` ** - filter based on a relation's field. use with ` $eager ` to also fetch the relation. See
159+ [ ` joinRelated ` ] ( https://vincit.github.io/objection.js/api/query-builder/join-methods.html#joinrelated )
162160 documentation.
163- - ** ` $joinEager ` ** - filter based on a relation's field using
164- ` JoinEagerAlgorithm ` . See
165- [ ` $joinEager ` ] ( https://vincit.github.io/objection.js/api/query-builder/eager-methods.html#joineager )
161+
162+ - ** ` $joinEager ` ** - filter based on a relation's field . See
163+ [ ` withGraphJoined ` ] ( https://vincit.github.io/objection.js/api/query-builder/eager-methods.html#withgraphjoined )
166164 documentation.
165+
167166- ** ` $modifyEager ` ** - filter relation based on a relation's field,
168167 e.g. ` companies.find({ query: { $eager: 'employees', $modifyEager: { employees: { name: 'John' } } } }) `
168+
169169- ** ` $mergeEager ` ** - merge an eager expression to ` $eager ` ,
170170 e.g. ` companies.find({ query: { $eager: 'employees', $mergeEager: 'ceos' } }) `
171- - ** ` $pick ` ** - pick properties from result models. See
172- [ ` pick ` ] ( https://vincit.github.io/objection.js/api/query-builder/other-methods.html#pick ) documentation.
173171
174172- ** ` $select ` ** - add SELECT statement with given array of column names. See
175173 [ ` $select ` ] ( https://vincit.github.io/objection.js/api/query-builder/find-methods.html#select ) documentation.
@@ -212,10 +210,8 @@ Note that all this eager related options are optional.
212210 [ ` transaction ` ] ( https://vincit.github.io/objection.js/api/objection/#transaction )
213211 documentation.
214212
215- - ** ` mergeAllowEager ` ** - Just like allowEager but instead of replacing query
216- builder’s allowEager expression this method merges the given expression to the
217- existing expression. See
218- [ ` mergeAllowEager ` ] ( https://vincit.github.io/objection.js/api/query-builder/eager-methods.html#mergealloweager )
213+ - ** ` mergeAllowEager ` ** - Will merge the given expression to the existing expression from the ` allowEager ` service option.
214+ See [ ` allowGraph ` ] ( https://vincit.github.io/objection.js/api/query-builder/eager-methods.html#allowgraph )
219215 documentation.
220216
221217### Composite primary keys
@@ -315,7 +311,7 @@ included in `$eager` query when using the `update` service method._
315311- **` allowedUpsert` ** - relation expression to allow relations to be upserted
316312 along with update. Defaults to ` null ` , meaning relations will not be
317313 automatically upserted unless specified here. See
318- [` allowUpsert ` ](https://vincit.github.io/objection.js/api/query-builder/mutate -methods.html#allowupsert )
314+ [` allowGraph ` ](https://vincit.github.io/objection.js/api/query-builder/eager -methods.html#allowgraph )
319315 documentation.
320316- **` upsertGraphOptions` ** - See
321317 [` upsertGraphOptions` ](https://vincit.github.io/objection.js/api/types/#type-upsertgraphoptions)
@@ -364,7 +360,7 @@ included in `$eager` query._
364360- **` allowedInsert` ** - relation expression to allow relations to be created
365361 along with insert. Defaults to ` null ` , meaning relations will not be
366362 automatically created unless specified here. See
367- [` allowInsert ` ](https://vincit.github.io/objection.js/api/query-builder/mutate -methods.html#allowinsert )
363+ [` allowGraph ` ](https://vincit.github.io/objection.js/api/query-builder/eager -methods.html#allowgraph )
368364 documentation.
369365- **` insertGraphOptions` ** - See
370366 [` insertGraphOptions` ](https://vincit.github.io/objection.js/api/types/#type-insertgraphoptions)
@@ -425,11 +421,6 @@ module.exports = function(app) {
425421 paginate,
426422 whitelist: [' $eager' , ' $joinRelation' ],
427423 allowedEager: ' [user, subtask]' ,
428- namedEagerFilters: {
429- unDone : function (builder ) {
430- builder .where (' done' , false );
431- }
432- },
433424 eagerFilters: [
434425 {
435426 expression: ' subtask' ,
@@ -533,7 +524,7 @@ class User extends Model {
533524 };
534525 }
535526
536- static get namedFilters () {
527+ static get modifiers () {
537528 return {
538529 active : builder => {
539530 builder .where (' status' , ' active' );
@@ -624,13 +615,16 @@ class Todo extends Model {
624615 };
625616 }
626617
627- static get namedFilters () {
618+ static get modifiers () {
628619 const knex = this .app .get (' knex' );
629620
630621 return {
622+ unDone : function (builder ) {
623+ builder .where (' complete' , false );
624+ },
631625 overdue : builder => {
632626 builder
633- .where (' complete' , ' = ' , false )
627+ .where (' complete' , false )
634628 .where (' dueDate' , ' <' , knex .fn .now ());
635629 }
636630 };
@@ -811,18 +805,30 @@ try {
811805
812806## Migrating to ` feathers- objection` v2
813807
814- ` feathers- objection` 2.0.0 comes with important security and usability updates.
808+ ` feathers- objection` 2.0.0 comes with important security and usability updates
815809
816- > **Important:** For general migration information to the new database adapter
817- > functionality see
818- > [crow.docs.feathersjs.com/migrating.html#database-adapters](https://crow.docs.feathersjs.com/migrating.html#database-adapters).
810+ > **Important:** For general migration information to the new database adapter functionality see
811+ > [crow.docs.feathersjs.com/migrating.html#database-adapters](https://crow.docs.feathersjs.com/migrating.html#database-adapters)
819812
820813The following breaking changes have been introduced:
821814
822815- All methods allow additional query parameters
823816- Multiple updates are disabled by default (see the ` multi` option)
824817- Objection related operators are disabled by default (see the ` whitelist`
825818 option)
819+
820+ ## Migrating to ` feathers- objection` v5
821+
822+ ` feathers- objection` 5.0.0 comes with usability updates and was migrated to use Objection v2
823+
824+ > **Important:** For general migration information to Objection v2 see
825+ > [https://vincit.github.io/objection.js/release-notes/migration.html](https://vincit.github.io/objection.js/release-notes/migration.html)
826+
827+ The following breaking changes have been introduced:
828+
829+ - ` $pick` query operator was removed
830+ - ` namedEagerFilters` service option was removed. use Model's [` modifiers` ](https://vincit.github.io/objection.js/recipes/modifiers.html#modifiers) instead
831+ - Model's ` namedFilters` property was renamed to ` modifiers`
826832
827833## License
828834
0 commit comments