Skip to content

Optimize multi patch when $returning is false. #382

Closed

Description

@DaddyWarbucks

I noticed this while making this comment: feathersjs/feathers#2472 (comment)

I believe we are potentially wasting some calls to _getOrFind if the user is using $returning: false. Note here:

const ids = this._getOrFind(id, idParams).then(result => {

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
if (params.$returning !== false) {

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.

Activity

  1. fratzinger commented on Jan 9, 2022

    @fratzinger
    Contributor

    don't forget about #363 and #364

  2. fratzinger commented on Jan 9, 2022

    @fratzinger
    Contributor

    return Promise.resolve([]);

    Should be return Promise.resolve(id == null ? [] : null)
    Same here:
    return Model.destroy(options).then(() => Promise.resolve([]))

    Or should $returning only supported for multi requests? If so, we need to handle this as well, like:

    if (params.$returning !== false) {

    if (params.$returning !== false && id == null)

  3. DaddyWarbucks commented on Nov 16, 2022

    @DaddyWarbucks
    ContributorAuthor

    Maybe relevant: #405

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions