feathers-sequelize icon indicating copy to clipboard operation
feathers-sequelize copied to clipboard

Optimize multi patch when $returning is false.

Open DaddyWarbucks opened this issue 3 years ago • 3 comments

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.

DaddyWarbucks avatar Jan 09 '22 18:01 DaddyWarbucks

don't forget about #363 and #364

fratzinger avatar Jan 09 '22 19:01 fratzinger

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)

fratzinger avatar Jan 09 '22 20:01 fratzinger

Maybe relevant: https://github.com/feathersjs-ecosystem/feathers-sequelize/issues/405

DaddyWarbucks avatar Nov 16 '22 21:11 DaddyWarbucks