0
我使用nodejs和mongoose。我有這樣的模式:在文檔中查找數組並按年份和月份篩選
var comptesSchema = new Schema ({
name: String,
solde: Number,
user_id: Number,
operations: [{
name: String,
amount: Number,
debit: Boolean,
mensuel: Boolean,
date: Date,
category: String
}]
});
和我DATAS:
[{
"_id": "5826d10b829c732cacd92f6f",
"name": "compte courant",
"__v": 0,
"solde": -40,
"operations": [
{
"date": "2016-11-12T23:00:00.000Z",
"debit": false,
"amount": 10,
"name": "tivoli",
"_id": "5828b1bf42ae876e287525dc"
},
{
"date": "2016-11-12T23:00:00.000Z",
"debit": false,
"amount": 20,
"name": "st georges",
"_id": "5828d1e1c951b07888e79c61"
},
{
"date": "2016-11-11T23:00:00.000Z",
"debit": false,
"amount": 10,
"name": "oiufdsouifd",
"_id": "5828d51e679a4a7718a55b48"
}
]}]
我想找到年份和月份的操作數組中的元素,和過濾。
你有什麼想法嗎?謝謝:)
它不起作用:(看我的答案 –