티스토리 뷰
이 시도
Account.find({
"createdAt": {
"$lte": "2016-10-08T16:21:40.935Z"
}
}, function(err, response) {
if (!err) {
console.log(response)
}
});
특정 데이터를 얻기 위해 범위를 정의 할 수도 있습니다.
Account.find({
"createdAt": {
"$gte": "2016-10-06T16:21:40.935Z",
"$lte": "2016-10-08T16:21:40.935Z"
}
}, function(err, response) {
if (!err) {
console.log(response)
}
});
-------------------이 조건을 넣어보세요 ...
{"createdAt": {'$gte': new Date('2016-10-01'), '$lt': new Date('2016-10-31')}}
이 두 날짜가 월 번호와 연도를 사용하여 동적으로 생성되도록하려면. 아래 코드를 입력하십시오.
const month = 10;
const year = 2016;
const fromDate = new Date(year, month, 1);
const toDate = new Date(fromDate.getFullYear(), fromDate.getMonth() + 1, 0);
const condition = {"createdAt": {'$gte': date, '$lte': lastDay}};
Account.find(condition, function(err, response){
if (!err){
console.log(response);
}
});
출처
https://stackoverflow.com/questions/39940162
댓글