Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to return value from original insert object #58

Closed
jayalfredprufrock opened this issue Jul 30, 2016 · 2 comments
Closed

Ability to return value from original insert object #58

jayalfredprufrock opened this issue Jul 30, 2016 · 2 comments

Comments

@jayalfredprufrock
Copy link
Contributor

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?

@jayalfredprufrock
Copy link
Contributor Author

Pull request: #63

@daffl
Copy link
Member

daffl commented Sep 14, 2016

Closed via #63 and 0a4cbbf

@daffl daffl closed this as completed Sep 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants