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
{{ message }}
Repository navigation
Use consistent $select in all methods, optimize select function #384
But it does not use the select function from adapters-commons on its results. All other methods do use this select function but not the attributes option. Is there a reason _get does not also use the attributes option? I don't see why it wouldn't work. The _find method should also use the select function.
If we use attributes in _get, then that should cover most other methods as they call _findOrGet under the hood. But _create uses Model.create and Model.bulkCreate and does not then call _findOrGet. I am curious if these Sequelize methods also support attributes.
If using attributes on all methods, is the select function even needed at that point? Even if not, it should likely be left in place for consistency across all adapter types. On the other hand, should we be using attributes at all and solely relying on the select function?
I am making an assumption that using atrributes on all methods would give us a performance boost. But, it generally makes sense that only selecting the columns we want returned at the SQL level would be better.
Furthermore, we should only use select function when there is a $select filter. Otherwise we are wasting loops. Even though select just returns result => result when there is no $select, with some simple conditionals we could check filters.$select then call select if needed. This is arguably a micro optimization when considering small results, but could make a difference with larger results. See: https://github.com/feathersjs/feathers/blob/dove/packages/adapter-commons/src/index.ts
My comments above about "only use select function when there is a $select filter" are incorrect. The function returned from select does not run its results.map function if there are no $select. This is already "optimized".
But, I don't think we have to call select on methods that call _findOrGet under the hood because they have already been selected. For Example, in the _remove method we are selecting twice
return(this._getOrFind(id,opts).then((data)=>{returnModel.destroy(options).then(()=>data);})// .then(select(params, this.id)) no need for this, _getOrFind handled it.catch(utils.errorHandler));
I also missed that update calls instance.update and could also use potentially use attributes.
Activity
DaddyWarbucks commentedon Jan 9, 2022
My comments above about "only use select function when there is a $select filter" are incorrect. The function returned from
selectdoes not run itsresults.mapfunction if there are no$select. This is already "optimized".But, I don't think we have to call
selecton methods that call_findOrGetunder the hood because they have already been selected. For Example, in the_removemethod we are selecting twiceI also missed that
updatecallsinstance.updateand could also use potentially useattributes.DaddyWarbucks commentedon Jan 9, 2022
Checklist of things to accomplish for this card
selectfunction on the_findmethodattributesoption on the_getmethodattributesoption on thecreatemethod, providedModal.createandModel.bulkCreatesupport it.attributesoption on theupdatemethod, providedinstance.updatesupports it.selectfrom the_patchmethodselectfrom the_removemethod