parse-server
parse-server copied to clipboard
ability to use allowDiskUse on mongo for find and count methods
New Feature / Enhancement Checklist
- [x] I am not disclosing a vulnerability.
- [x] I am not just asking a question.
- [x] I have searched through existing issues.
Current Limitation
currently it's not possible to set allowDiskUse as option to queries
Feature / Enhancement Description
according to this comment, starting with mongo v5.12.8 it would be possible to pass allowDiskUse through setOptions
https://github.com/Automattic/mongoose/issues/10177#issuecomment-836868781
await Test.find().sort({ name: 1 }).setOptions({ allowDiskUse: true }).exec();
Example Use Case
query.find({ allowDiskUse: true }).then(function(results) {
// Request succeeded
}, function(error) {
// Request failed
});
Alternatives / Workarounds
N/A
3rd Party References
N/A
Thanks for opening this issue!
- 🎉 We are excited about your ideas for improvement!
That sounds like a good addition, allowDiskUse has been added in MongoDB 4.4.
Yo @mtrezza
Do you think that would be too crazy to implement? I'm willing to set up parse for dev and have a shot
I think it would be straight forward to implement. It's just another option that can be passed in Parse.Query which is then passed through to the MongoDB driver. You could take a look at Parse.Query.readPreference for how an option is passed to the driver. You would basically replicate that and rename it Parse.Query.allowDiskUse.
Hello @stewones can you implement it for aggregates too? Otherwise I will do it later.
It seems that no PR has ever been submitted for this issue, so feel free to submit one.
hey guys, I've left the company I was working for which would benefit from this feature, so completely lost the interest for now. but would love to see this feature added.
alright I need this for a pet project now, looking into 👀
got it working for the find method, now need to add tests and support aggregate as well.
PR coming in a few hours 🫡
@mtrezza
would be super awesome to get some feedback asap on this PR https://github.com/parse-community/Parse-SDK-JS/pull/1619
we gonna need it for the new feature
in order to use allowDiskUse mongo requires at least one sort otherwise an error is thrown by Mongo but ParseError can't recognize it causing [object Object] as a log message, which in turn makes it impossible to figure what's going on.
once that PR ^ is accepted Parse will be able to print those errors like this

How is this feature dependent on or related to https://github.com/parse-community/Parse-SDK-JS/pull/1619? That PR seems to be only about making log messages more readable.
Sorry I expressed myself badly, too much excitement 🙈
It's not dependent, actually, it's just frustrating cause Parse should print errors like in that ^ screenshot but it doesn't. So user wants to use allowDiskUse, an error is thrown and they don't know that this option requires a sort. that PR fixes it and other edge cases.. like I got a Parse server running monitored by GCP Error Reporting and I currently can't figure out some errors due to this issue. Error message gets blank.
Got it, let me mark this as off-topic, as these comments really belong to the other issue it seems. I reviewed the other PR and posted some thoughts. Let's continue the discussion there.
allowDiskUse is true by default in mongo 6. If Parse let the default option, it will work with an upgrade of mongo version.
Maybe it still makes sense to add the option, as there will be deployments running on MongoDB <6 for a while, probably years?
created a draft. it already works with find
https://github.com/parse-community/parse-server/pull/8337
That sounds like a good addition,
allowDiskUsehas been added in MongoDB 4.4.
Do not think, this included the aggregation queries. It only mentions the find and the sort operation.
Could you explain a bit more?