Merge pull request #12 from fantasticit/bugfix/createWiki

This commit is contained in:
fantasticit 2022-03-24 16:10:41 +08:00 committed by GitHub
commit ca7f18e640
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 3 deletions

View File

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