Query when using .stream() method does not understand Strings as ObjectIDs or Dates
See original GitHub issueWhen running a find() and then stream() as per below
Model.find({
"_id":{
"$in":["5aa8f1226744783cd807a817"]
},
"date":{
"$gte":"2019-08-14T23:38:17.123Z"
}
})
.lean()
.batchSize(100)
.stream();
Mongoose does not cast the “5aa8f1226744783cd807a817” as an ObjectID, neither does it cast “2019-08-14T23:38:17.123Z” as a Date, it runs the query with those values typed as a String and doesn’t return match the records from the database.
However running the same query with the .exec() method works correctly.
Model.find({
"_id":{
"$in":["5aa8f1226744783cd807a817"...]
},
"date":{
"$gte":"2019-08-14T23:38:17.123Z"
}
})
.lean()
.exec(function(err, docs) {
});
This has only been an issue since we upgraded to a recent version of Mongoose
Issue Analytics
- State:
- Created 4 years ago
- Comments:5
Top Results From Across the Web
Java 8 Streams: How to call once the Collection.stream ...
Is it possible to do a single call to the stream() method and to return the array of objects directly ? Object[] result...
Read more >A Guide to Java Streams in Java 8: In-Depth Tutorial ... - Stackify
This in-depth tutorial is an introduction to the many functionalities supported by streams, with a focus on simple, practical examples. To ...
Read more >Processing Data with Java SE 8 Streams, Part 1 - Oracle
We first get a stream from the list of transactions by calling the stream() method. The datasource is the list of transactions and...
Read more >How to Filter Stream and Collections in Java 8? Example ...
You first need to obtain a stream from Collection by calling stream() method and then you can use the filter() method, which takes...
Read more >Working with datetime as string - MongoDB
They store this value as an ISO 8601 formatted string ... Can I still run date time queries on it, even though it's...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Which version of mongoose did you upgrade to? stream() is no longer supported, it’s been replaced by cursor() : https://thecodebarbarian.com/cursors-in-mongoose-45
I’m unable to find any indication that
cursor()
is orders of magnitude slower thanstream()
. Consider the below script:Mongoose 5.7 using
cursor()
:Mongoose 4.13 using
stream()
:How are you iterating through the stream?