1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-02-01 19:15:01 +02:00

Server: Fixed file count issue for PostgreSQL

This commit is contained in:
Laurent Cozic 2020-12-29 23:48:34 +00:00
parent e61e8b7b94
commit f48697572d

View File

@ -348,8 +348,8 @@ export default class FileModel extends BaseModel {
public async childrenCount(id: string): Promise<number> {
const parent = await this.load(id);
await this.checkCanReadPermissions(parent);
const r = await this.db(this.tableName).select('id').where('parent_id', id).count('id', { as: 'total' });
return r.length && r[0].total ? r[0].total : 0;
const r = await this.db(this.tableName).where('parent_id', id).count('id', { as: 'total' });
return Number(r);
}
public async childrens(id: string, pagination: Pagination): Promise<PaginatedFiles> {