This commit is contained in:
fantasticit 2022-03-24 16:07:32 +08:00
parent 088b7f0357
commit c8ee4974ef
1 changed files with 7 additions and 3 deletions

View File

@ -300,9 +300,13 @@ export class DocumentService {
userId: user.id, userId: user.id,
}); });
const query = this.documentRepo.createQueryBuilder('documemt'); const [docs] = await this.documentRepo.findAndCount({ createUserId: user.id });
query.select('MAX(documemt.index)', 'maxIndex'); const maxIndex = docs.length
const { maxIndex } = await query.getRawOne(); ? Math.max.apply(
[],
docs.map((doc) => +doc.index)
)
: -1;
const data = { const data = {
...dto, ...dto,