queryBuilder EXISTS query
See original GitHub issueIssue type:
[ ] question [ ] bug report [x] feature request [ ] documentation issue
Database system/driver:
[ ] cordova
[ ] mongodb
[ ] mssql
[x] mysql / mariadb
[ ] oracle
[ ] postgres
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo
TypeORM version:
[x] latest
[ ] @next
[ ] 0.x.x (or put your version here)
Feature request:
Looks like EXISTS is optimised more, if you need to check only rows existence. So, instead of
SELECT COUNT(*) FROM mytable WHERE a = "foo" AND b = "bar";
better do
SELECT EXISTS(SELECT * FROM mytable WHERE a = "foo" AND b = "bar");
But now query builder doesn’t support such kind of queries, you need to write a raw query. I think it would be cool to have something like
queryBuilder()
.select('*')
.from(MyTable, 'tbl')
.where('tbl.a = :foo AND tbl.b = :bar', { foo, bar })
.isExists(); // <-- this row
Issue Analytics
- State:
- Created 5 years ago
- Reactions:80
- Comments:19 (3 by maintainers)
Top Results From Across the Web
Running "exists" queries in Laravel query builder
I'm using MySQL and have a table of 9 million rows and would like to quickly check if a record (id) exists or...
Read more >Java Examples & Tutorials of QueryBuilders.existsQuery (org ...
Best Java code snippets using org.elasticsearch.index.query.QueryBuilders.existsQuery (Showing top ... existsQuery(field)); filterQuery.must(QueryBuilders.
Read more >Query Builder - Laravel - The PHP Framework For Web Artisans
Laravel's database query builder provides a convenient, fluent interface to creating and running database queries. It can be used to perform most database ......
Read more >Exists query | Elasticsearch Guide [8.5] | Elastic
Exists query edit. Returns documents that contain an indexed value for a field. An indexed value may not exist for a document's field...
Read more >Laravel Query Builder Where Exists Example - Medium
The database query builder in Laravel provides a simple, intuitive interface for generating and performing database queries. It works with every one of ......
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
I use this:
I made little helper
and use it like this:
But native support from TypeORM would be better, of course 😃