-
- Notifications
You must be signed in to change notification settings - Fork 3.9k
Closed
Milestone
Description
I'm running a single node replica (version 2.6.4) set in my development setup using Mongoose version 3.8.20.
My aggregate queries look something like this:
MyModel.aggregate({ $match: { createdAt: { $gte: start, $lte: end } } }, { $group: { _id: { day: {$dayOfMonth: "$createdAt"}, month: {$month: "$createdAt"}, year: {$year: "$createdAt"} }, count: {$sum: 1} } }) .read("secondary") .exec(callback); Ordinarily my read preference is set to "secondaryPreferred" because I'm running a single node for testing and development while there's a replica set in production. However I swapped read preference to "secondary" just to reassure myself that my query was sensitive to read() and contrary to what I expected, the query ran just fine. I did not receive any error to my callback.
According to the documentation for Query#read, querying with secondary should return an error if no secondaries are available. Is the behaviour for Aggregate#read meant to differ?
Additional Info:
- My schema read preference is left as default ("primary") - changing it does not make a difference
- The query runs fine with using any setting: E.g. nearest, primaryPreferred, etc
- The query fails as expected if I pass
readsome random string
Lwdthe1
Metadata
Metadata
Assignees
Labels
No labels