-
Notifications
You must be signed in to change notification settings - Fork 39
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
getBy
and select
should ideally also return the AutoKey
#16
Comments
Perhaps it is better not to change default types of I am fine with adding replaceBy. |
Hmm. Maybe we can borrow the "Entity" concept from persistent for these cases - the combination of the AutoKey and the object. So they can be something like Also, I think it would be great to add (I've already needed it) something like the following that replace the conditions with a unique constraint:
The basic idea being to add a "by-unique-constraint" version for every operation that otherwise indexes either by AutoKey or by conditions. Thoughts? |
I like the idea of using Entity as part of the name.
|
Right, but that only works when the unique constraint is a single field. The major benefit from what I was describing above is being able to use a I was thinking something like: update myUpdates (extractUnique myRecord :: Key Artist (Unique SomeFields)) On Tuesday, December 3, 2013, Boris Lykah wrote:
Ozgun Ataman CEO Soostone Inc. +1 917 725 0849 (Office) |
This works for the composite keys too like an embedded field. |
Could you give an example? Sent from my iPhone
|
Here the key has two fields
|
Oh, that's great! What I didn't know was that you can do Thanks! |
Going to resurrect this thread. @lykahb it seems like this feature is still necessary. If you want to search records and be able to look them up by autokey later, I think you would have to look them back up through a projection. Have your thoughts changed on this feature? |
Not every entity has an autokey so I am hesitant about adding it to the getBy and select. Projection can serve as both and it is only a little more verbose than getBy. Or do you have a different use case in mind? |
Hmm, that's fine. I actually discovered that our company had solved this in the groundhog-utils module. Not sure if this strategy should be mentioned in documentation or maybe even ported to groundhog proper in some way. Up to you. |
With
getBy
defined as below, it is often inconvenient to lookup by a unique key followed by and update or a replace. IfgetBy
also returned the AutoKey for the record in question, that can then easily be used for subsequent operations.Same applies to
select
- it is most often better to use the more verboseproject
to get both the AutoKey and the constructor.Given AutoKey is very central to groundhog's API (many ops require it), it may be better to return it by default in these kinds of operations.
Conversely, it would be useful to define a new
replaceBy
function that uses a unique key to perform replacement.The text was updated successfully, but these errors were encountered: