'How can I Query for these specific data in MongoDB
I have a schema defined as
{
category: {
type: mongoose.Schema.ObjectId,
ref: "Categories",
required: true,
},
exit: String,
transfer: String,
deathDate: Date,
sex: {
type: String,
enum: ["Male", "Female", "Unspecified"],
required: true,
},
createdAt: {
type: Date,
default: Date.now,
}
}
How can I get the specific data mentioned below by querying the database?
Category | Till Last Week | This week Data | Exit | Transfer | Death | Remaining | Males | Females | Unspecified |
---|---|---|---|---|---|---|---|---|---|
620aaecdcf85f5dfc0d6c5f6 | 10 | 5 | 1 | 2 | 1 | 11 | 1 | 1 | 9 |
62349f03821de1f2651aea78 | 3 | 1 | 2 | 1 | 0 | 1 | 0 | 0 | 1 |
620aaf30cf85f5dfc0d6c60a | 10 | 2 | 8 | 4 | 0 | 0 | 0 | 0 | 0 |
I want to generate such a table each Monday.
Thanks in advance
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|