Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using Date query with $gte and $lte operators. #248

Closed
shubhanshusingh opened this issue Dec 12, 2019 · 3 comments
Closed

using Date query with $gte and $lte operators. #248

shubhanshusingh opened this issue Dec 12, 2019 · 3 comments

Comments

@shubhanshusingh
Copy link

shubhanshusingh commented Dec 12, 2019

var fdb = new ForerunnerDB();
var cdb = fdb.db("compute");
var fdbcollection = cdb.collection("vipData").deferredCalls(false);

vipPass = vipPass.map(function (vp) {
 console.log(vp.vip_end
 instanceof
 Date)

 return {
 u_id: vp.u_id,
 vip_end: fdb.make(vp.vip_end),
 vip_start: fdb.make(vp.vip_start)
}
})
// insert data into forerunner db
fdbcollection.insert(vipPass)

console.log("DATA inserted into forerunner.")
// query data based on operator based date.
let results = fdbcollection.find({
u_id: singleTxnObj.u_id,
// vip_end: {$lte: singleTxnObj.createdAt.toString()},
// vip_start: {$gte: singleTxnObj.createdAt.toString()}
}, {
$limit: 1
});

console.log(singleTxnObj.createdAt instanceof Date) //true
console.log(luxon.DateTime.fromISO(singleTxnObj.createdAt.toString()).toJSDate() instanceof Date) // true

console.log(results[0].vip_end instanceof Date) // true
console.log(results[0].vip_start instanceof Date) // true



as per the code above I have inserted Date fields with other fields and also in case of results from query I can see that the fields are instance of Date.

I have used fdb.make, but the result based on $gte & $lte doesn't work, as it doesn't return any data results.

Wanted to know if $gte & $lte can be applied to queries like these?

@shubhanshusingh shubhanshusingh changed the title using Date to with $gte and $lte operators. using Date query with $gte and $lte operators. Dec 12, 2019
@Irrelon
Copy link
Owner

Irrelon commented Dec 12, 2019 via email

@Irrelon
Copy link
Owner

Irrelon commented Dec 12, 2019

Hey I notice this is closed, did that solve the problem?

@shubhanshusingh
Copy link
Author

toString() was one of the problem, the query with those fields. $lte should be $gte and vice-versa, my bad.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants