Skip to content

Ability to return value from original insert object #58

@jayalfredprufrock

Description

@jayalfredprufrock

I just ran into a big issue that is largely a result of how knex works, issue here: knex/knex#95

Basically Knex inserts for MySQL can only return auto-increment primary keys. I'm generating my own UUIDs for some of my tables which causes the "create" service method to fail, since it is unable to retrieve the newly created user using "get" because the primary key is not available.

The easiest way to fix this would be to provide the ability to return a property from the original object being inserted. I'm happy to submit a pull request for this, but I'm not sure of the best way to expose this functionality. We can either add a flag option that indicates the "id" option specified should be pulled from the original object, or use a convention like if the "id" begins with a "." then the value should be retrieved from the original object instead of the result from knex. Thoughts?

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