Problems working with repository.count
See original GitHub issueIssue type:
[x] question [x] bug report [ ] feature request [ ] documentation issue
Database system/driver:
[ ] cordova
[x] mongodb
[ ] mssql
[ ] mysql
/ mariadb
[ ] oracle
[ ] postgres
[ ] cockroachdb
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo
TypeORM version:
[x] latest
[ ] @next
[ ] 0.x.x
(or put your version here)
Steps to reproduce or a small repository showing the problem:
@Entity()
export abstract class EntityAbstract {
@ObjectIdColumn()
_id: ObjectID;
@Column()
name: string;
@CreateDateColumn({type: 'timestamp', update: true})
createdAt: Date;
@UpdateDateColumn({type: 'timestamp'})
updatedAt: Date;
@Column({type: 'timestamp'})
deletedAt: Date;
}
console.log(await this.repository.find({where: {deletedAt: {$exists: true}}})); // ok, return 2 record
console.log(await this.repository.count({where: {deletedAt: {$exists: true}}})); // opps, return 0
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
GitHub API: how efficiently get the total count of Issues per ...
Using Rest API, you can use the search api: GET https://api.github.com/search/issues?q=repo:bertrandmartel/tableau-scraping%20is:issue.
Read more >Native Queries with Spring Data JPA
Add a Count Query to Enable Pagination. When working with a custom JPQL query, you can add a parameter of type Pageable to...
Read more >Q & A
Working with Repositories - need for a blank (0.0.0.0/0) repository? Recently we have had issues where static IP asset groups would not display...
Read more >Customizing the Result of JPA Queries with Aggregation ...
The result of the previous JPA query can't be loaded into an instance of Comment because the result is a different shape. The...
Read more >Wrong repository count on profile : r/github
Just realized how to fix it. It seems it doesn't count the repositories for which you change the visibility until you create a...
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 FreeTop 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
Top GitHub Comments
I ran also into this issue when Using
Repository
.The problem is the typings.
The more generic
Repository
class has three signatures for count:But
MongoRepository
implementation only hasThis is equivalent to the second signature, the one with
FindConditions
So in case you are using Mongo you can only use the second signature from Repository
You have two options:
MongoRepository
and get the correct typingsPerhaps not a best way to address the issue, but let me do it here for start and we can move it in a separate issue if needed.
Issue type:
[ ] question [x] bug report [ ] feature request [ ] documentation issue
Database system/driver:
[ ]
cordova
[ ]mongodb
[ ]mssql
[x]mysql
/mariadb
[ ]oracle
[ ]postgres
[ ]cockroachdb
[ ]sqlite
[ ]sqljs
[ ]react-native
[ ]expo
TypeORM version:
[ ]
latest
[ ]@next
[x]0.2.18
(or put your version here)Steps to reproduce or a small repository showing the problem:
I can reproduce the same issue with mysql driver. Seem like that repository.count is not returning correct count results in my case as well.
have a simple condition in it:
repository.count({ ColumnA: valueA, ColumnB: ValueB });