-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug-controller.js
More file actions
59 lines (50 loc) · 1.46 KB
/
debug-controller.js
File metadata and controls
59 lines (50 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
const { PrismaClient } = require('@prisma/client');
async function debugController() {
const prisma = new PrismaClient();
try {
// Simulate the controller logic
const page = 1;
const limit = 5;
const skip = (page - 1) * limit;
const where = {};
const orderBy = { createdAt: 'desc' };
console.log('Query params:', { skip, take: limit, where, orderBy });
const [transactions, total] = await Promise.all([
prisma.cryptoTransaction.findMany({
skip,
take: limit,
where,
orderBy,
include: {
user: { select: { firstName: true, lastName: true, email: true } },
asset: true,
network: true,
bankAccount: true,
},
}),
prisma.cryptoTransaction.count({ where }),
]);
console.log('Transactions found:', transactions.length);
console.log('Total count:', total);
console.log('First transaction:', JSON.stringify(transactions[0], null, 2));
const response = {
success: true,
data: transactions,
pagination: {
page,
limit,
total,
pages: Math.ceil(total / limit),
hasNext: page * limit < total,
hasPrev: page > 1,
},
};
console.log('Response structure:', JSON.stringify(response, null, 2));
} catch (error) {
console.error('Error:', error.message);
console.error('Stack:', error.stack);
} finally {
await prisma.$disconnect();
}
}
debugController();