style: apply standard ESLint & Prettier formatting across backend
Deploy Canina / deploy (push) Successful in 4m58s
Deploy Canina / deploy (push) Successful in 4m58s
This commit is contained in:
1 parent
ae636c8b03
commit
62bd8811fa
66 files changed
+1398
-607
No files matched your search
@@ -8,23 +8,39 @@ export class PetsService {
|
||||
async getPets(query: any) {
|
||||
const { page = 1, limit = 10, search = '' } = query;
|
||||
const skip = (Number(page) - 1) * Number(limit);
|
||||
|
||||
const where = search ? { name: { contains: search, mode: 'insensitive' as any } } : {};
|
||||
|
||||
|
||||
const where = search
|
||||
? { name: { contains: search, mode: 'insensitive' as any } }
|
||||
: {};
|
||||
|
||||
const [data, total] = await Promise.all([
|
||||
this.prisma.pet.findMany({
|
||||
where,
|
||||
skip,
|
||||
take: Number(limit),
|
||||
orderBy: { createdAt: 'desc' },
|
||||
include: { user: { select: { firstName: true, lastName: true, email: true, mobile: true } } }
|
||||
include: {
|
||||
user: {
|
||||
select: {
|
||||
firstName: true,
|
||||
lastName: true,
|
||||
email: true,
|
||||
mobile: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
this.prisma.pet.count({ where })
|
||||
this.prisma.pet.count({ where }),
|
||||
]);
|
||||
|
||||
return {
|
||||
data,
|
||||
meta: { total, page: Number(page), limit: Number(limit), lastPage: Math.ceil(total / Number(limit)) }
|
||||
meta: {
|
||||
total,
|
||||
page: Number(page),
|
||||
limit: Number(limit),
|
||||
lastPage: Math.ceil(total / Number(limit)),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user