fix(admin): bulk APIs — include->select for _count (Prisma 6.19 select+include conflict)
This commit is contained in:
@@ -34,7 +34,7 @@ export async function GET(request: NextRequest) {
|
|||||||
db.lead.count({ where }),
|
db.lead.count({ where }),
|
||||||
db.lead.findMany({
|
db.lead.findMany({
|
||||||
where,
|
where,
|
||||||
include: {
|
select: {
|
||||||
_count: {
|
_count: {
|
||||||
select: { chatSessions: true },
|
select: { chatSessions: true },
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -28,7 +28,19 @@ export async function GET(request: NextRequest) {
|
|||||||
db.product.count({ where }),
|
db.product.count({ where }),
|
||||||
db.product.findMany({
|
db.product.findMany({
|
||||||
where,
|
where,
|
||||||
include: {
|
select: {
|
||||||
|
id: true,
|
||||||
|
name: true,
|
||||||
|
description: true,
|
||||||
|
privateData: true,
|
||||||
|
price: true,
|
||||||
|
quantityInStock: true,
|
||||||
|
photoUrl: true,
|
||||||
|
hiddenPhotoUrl: true,
|
||||||
|
hiddenCoordinates: true,
|
||||||
|
hiddenDescription: true,
|
||||||
|
isMono: true,
|
||||||
|
createdAt: true,
|
||||||
category: { select: { id: true, name: true } },
|
category: { select: { id: true, name: true } },
|
||||||
subcategory: { select: { id: true, name: true } },
|
subcategory: { select: { id: true, name: true } },
|
||||||
location: { select: { id: true, country: true, city: true, district: true } },
|
location: { select: { id: true, country: true, city: true, district: true } },
|
||||||
|
|||||||
@@ -25,9 +25,27 @@ export async function GET(request: NextRequest) {
|
|||||||
const [data, total] = await Promise.all([
|
const [data, total] = await Promise.all([
|
||||||
db.purchase.findMany({
|
db.purchase.findMany({
|
||||||
where,
|
where,
|
||||||
include: {
|
select: {
|
||||||
user: { select: { username: true, telegramId: true } },
|
id: true,
|
||||||
product: { select: { name: true } },
|
userId: true,
|
||||||
|
productId: true,
|
||||||
|
walletType: true,
|
||||||
|
txHash: true,
|
||||||
|
quantity: true,
|
||||||
|
totalPrice: true,
|
||||||
|
purchaseDate: true,
|
||||||
|
status: true,
|
||||||
|
user: {
|
||||||
|
select: {
|
||||||
|
username: true,
|
||||||
|
telegramId: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
product: {
|
||||||
|
select: {
|
||||||
|
name: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
orderBy: { id: 'desc' },
|
orderBy: { id: 'desc' },
|
||||||
skip: (page - 1) * limit,
|
skip: (page - 1) * limit,
|
||||||
|
|||||||
@@ -20,9 +20,18 @@ export async function GET(request: NextRequest) {
|
|||||||
db.transaction.count({ where }),
|
db.transaction.count({ where }),
|
||||||
db.transaction.findMany({
|
db.transaction.findMany({
|
||||||
where,
|
where,
|
||||||
include: {
|
select: {
|
||||||
|
id: true,
|
||||||
|
userId: true,
|
||||||
|
walletType: true,
|
||||||
|
txHash: true,
|
||||||
|
amount: true,
|
||||||
|
createdAt: true,
|
||||||
user: {
|
user: {
|
||||||
select: { username: true, telegramId: true },
|
select: {
|
||||||
|
username: true,
|
||||||
|
telegramId: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
orderBy: { createdAt: 'desc' },
|
orderBy: { createdAt: 'desc' },
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ export async function GET(request: NextRequest) {
|
|||||||
db.tgUser.count({ where }),
|
db.tgUser.count({ where }),
|
||||||
db.tgUser.findMany({
|
db.tgUser.findMany({
|
||||||
where,
|
where,
|
||||||
include: {
|
select: {
|
||||||
_count: {
|
_count: {
|
||||||
select: { wallets: true, purchases: true },
|
select: { wallets: true, purchases: true },
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -24,7 +24,15 @@ export async function GET(request: NextRequest) {
|
|||||||
|
|
||||||
const users = await db.tgUser.findMany({
|
const users = await db.tgUser.findMany({
|
||||||
where,
|
where,
|
||||||
include: {
|
select: {
|
||||||
|
id: true,
|
||||||
|
username: true,
|
||||||
|
telegramId: true,
|
||||||
|
status: true,
|
||||||
|
totalBalance: true,
|
||||||
|
bonusBalance: true,
|
||||||
|
country: true,
|
||||||
|
city: true,
|
||||||
_count: {
|
_count: {
|
||||||
select: { wallets: true },
|
select: { wallets: true },
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user