[{
"_id": {
"$oid": "5d7a76c94c3c8c05618cef58"
},
"title": "hello",
"date": {
"$date": "2019-06-07T07:22:00.000Z"
},
"__v": 0
}, {
"_id": {
"$oid": "5d7a7809ef31980615ed3756"
},
"title": "hello",
"date": {
"$date": "2019-06-08T07:22:00.000Z"
},
"__v": 0
}, {
"_id": {
"$oid": "5d7a78e712c75706a3fdb025"
},
"title": "hello6",
"date": {
"$date": "2019-07-19T08:22:00.000Z"
},
"__v": 0
}, {
"_id": {
"$oid": "5d7a78e712c75706a3fdb025"
},
"title": "hello7",
"date": {
"$date": "2019-07-03T08:22:00.000Z"
},
"__v": 0
}]
我正在使用 mongoose 将我的数据存储在 mongodb 中,我正在尝试使用 mongoose
我想要从日期2019-07-01到的所有文档。2019-07-31我们可以在 mongoDB 中对 mongoose 执行此过滤器吗
预期产出
[
{
"_id": {
"$oid": "5d7a78e712c75706a3fdb025"
},
"title": "hello6",
"date": {
"$date": "2019-07-19T08:22:00.000Z"
},
"__v": 0
}, {
"_id": {
"$oid": "5d7a78e712c75706a3fdb025"
},
"title": "hello7",
"date": {
"$date": "2019-07-03T08:22:00.000Z"
},
"__v": 0
}
]
这是我的代码 https://codesandbox.io/s/lively-tree-hd0fo
app.get("/saveData", async () => {
try {
var blog = new BlogPostModel({
title: "hello6",
date: "19-Jul-2019 08:22"
});
console.log("before save");
let saveBlog = await blog.save(); //when fail its goes to catch
console.log(saveBlog); //when success it print.
console.log("saveBlog save");
} catch (error) {
console.log(error);
}
});
桃花长相依
相关分类