Single object lookup by unique key
See original GitHub issueIt would be useful if we could lookup single objects by their unique fields other than the primary key.
user_by_email(email: "an@example.org") { id email }
For composed unique fields it could be something along the lines of
order_by_user_id_and_invoice_id(user_id: 1, invoice_id: 1) { id email }
I presume we could automatically get this functionality based on the unique indexes in postgresql. It is a bit nicer than with the where clause when we know there will only be a single item.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:60
- Comments:15 (1 by maintainers)
Top Results From Across the Web
How to get objects with unique values for specific keys from ...
What I tried is to itterate through array, but this way I can get only unique object within one key. I can't figure...
Read more >Keyed collections - JavaScript - MDN Web Docs
Use objects when there is logic that operates on individual elements. WeakMap object. A WeakMap is a collection of key/value pairs whose keys...
Read more >Query | GORM - GORM
Retrieving a single object ; // Get the first record ordered by primary key db.First(&user) // SELECT * FROM users ORDER BY id...
Read more >Object that maps unique keys to values - MATLAB - MathWorks
A Map object is a data structure that allows you to retrieve values using a corresponding key.
Read more >object - SAP AppGyver Documentation
Lookup. Returns the value associated with the given key in the given object. ... Given a list of objects, returns a single object...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Would be nice if we had a query_by_uk exactly like query_by_pk but base on the unique keys, this way we don’t need to use the search queries that return an array.
This would greatly help