add findOne() to query builder#440
Conversation
|
|
I'd definitely find an API like this to retrieve just a single row helpful. |
|
@fcannizzaro just letting you know this hasn't dropped off my radar, we discussed it in a meeting today and are going to push through with adding this findOne api. I'll get back to you with a proper review and some guidance tomorrow. |
6196879 to
c18e878
Compare
More templates
@tanstack/angular-db
@tanstack/db
@tanstack/db-ivm
@tanstack/electric-db-collection
@tanstack/query-db-collection
@tanstack/react-db
@tanstack/rxdb-db-collection
@tanstack/solid-db
@tanstack/svelte-db
@tanstack/trailbase-db-collection
@tanstack/vue-db
commit: |
|
Hi @fcannizzaro, I'm finally catching up on this. I've rebased your branch on main, and fixed a couple of things. One addition is that it now supports specifying @kevin-dp could you take a look at this, you may know of a cleaner way to do this. |
c18e878 to
61b66a5
Compare
kevin-dp
left a comment
There was a problem hiding this comment.
Great work. I left a few minor comments that we should address to improve maintainability.
samwillis
left a comment
There was a problem hiding this comment.
This is looking great @fcannizzaro, I think we are nearly there.
It looks like there is a type error throwing in CI, once thats fixed I suspect we are ready to approve.
|
@samwillis Can you check what's the error ? Locally |
|
Seems to be in the react-db package: https://github.com/TanStack/db/actions/runs/18129520557/job/51592548474?pr=440 |
|
It seems a vite configuration error (?) |
samwillis
left a comment
There was a problem hiding this comment.
I fixed the type issue in another pr, then merged in main. All good now.
Just going to merge!
Thanks @fcannizzaro! 🥳
Hi! I've implemented the
findOne()in the query builder (#182) for db and react-db.When
findOne()is chained in the query builder, I store asinglevariable in the context (extending also the context type for the inference) that is then inherited from the collection config to allow thedatagetter to return a single row or an array.I also tested both
db/testandreact-db/test(by adding also a dedicated test for this feature).LMK if it's ok to do like this or if you have some better ideas.