feathers-sequelize
feathers-sequelize copied to clipboard
Optimize multi patch when $returning is false.
I noticed this while making this comment: https://github.com/feathersjs/feathers/pull/2472#issuecomment-1008349932
I believe we are potentially wasting some calls to _getOrFind if the user is using $returning: false. Note here: https://github.com/feathersjs-ecosystem/feathers-sequelize/blob/db4b5ff9b89df9b163f9cd5d8c32de8c915ff71c/lib/index.js#L222
that we are fetching the idList so that the modified results can be returned. But, we don't know for certain that the results need to be returned until https://github.com/feathersjs-ecosystem/feathers-sequelize/blob/db4b5ff9b89df9b163f9cd5d8c32de8c915ff71c/lib/index.js#L245
We should move some code around so that we are not fetching the idList until we check if params.$returning !== false. The _remove method does this. So we should update patch to work similarly.
don't forget about #363 and #364
https://github.com/feathersjs-ecosystem/feathers-sequelize/blob/db4b5ff9b89df9b163f9cd5d8c32de8c915ff71c/lib/index.js#L248
Should be return Promise.resolve(id == null ? [] : null)
Same here:
https://github.com/feathersjs-ecosystem/feathers-sequelize/blob/db4b5ff9b89df9b163f9cd5d8c32de8c915ff71c/lib/index.js#L300
Or should $returning only supported for multi requests? If so, we need to handle this as well, like:
https://github.com/feathersjs-ecosystem/feathers-sequelize/blob/db4b5ff9b89df9b163f9cd5d8c32de8c915ff71c/lib/index.js#L293
if (params.$returning !== false && id == null)
Maybe relevant: https://github.com/feathersjs-ecosystem/feathers-sequelize/issues/405