mirror of https://github.com/fantasticit/think.git
close #11
parent
088b7f0357
commit
c8ee4974ef
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue