-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheckProblems.js
More file actions
39 lines (32 loc) · 1.45 KB
/
checkProblems.js
File metadata and controls
39 lines (32 loc) · 1.45 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
import models from './models.js';
async function checkProblems() {
try {
const count = await models.MathProblem.countDocuments();
console.log(`\n✅ Total math problems in database: ${count}\n`);
const samples = await models.MathProblem.find().limit(10);
if (samples.length > 0) {
console.log('Sample problems:');
console.log('─'.repeat(40));
samples.forEach((p, i) => {
console.log(`${i + 1}. ${p.problem} = ${p.answer}`);
});
console.log('─'.repeat(40));
} else {
console.log('No problems found in database yet.');
}
const addition = await models.MathProblem.countDocuments({ problem: { $regex: /\+/ } });
const subtraction = await models.MathProblem.countDocuments({ problem: { $regex: /-/ } });
const multiplication = await models.MathProblem.countDocuments({ problem: { $regex: /×/ } });
const division = await models.MathProblem.countDocuments({ problem: { $regex: /÷/ } });
console.log('\nBreakdown:');
console.log(` Addition (+): ${addition}`);
console.log(` Subtraction (-): ${subtraction}`);
console.log(` Multiplication (×): ${multiplication}`);
console.log(` Division (÷): ${division}\n`);
process.exit(0);
} catch (error) {
console.error('Error checking problems:', error);
process.exit(1);
}
}
checkProblems();