We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi @JKHeadley ! 👋
Firstly, thanks for your work on this project! 🙂
Regarding the issue #296. Today I used patch-package to patch [email protected] for the project I'm working on.
[email protected]
Here is the diff that solved my problem:
diff --git a/node_modules/rest-hapi/utilities/handler-helper.js b/node_modules/rest-hapi/utilities/handler-helper.js index e0334e5..a13b2ed 100644 --- a/node_modules/rest-hapi/utilities/handler-helper.js +++ b/node_modules/rest-hapi/utilities/handler-helper.js @@ -148,6 +148,23 @@ async function _listHandler(model, request, Log) { if (query.$flatten) { flatten = true } + + if ( query.$startDate || query.$endDate ) { + query.createdAt = {} + + if ( query.$startDate ) { + query.createdAt.$gte = new Date( query.$startDate ) + + delete query.$startDate; + } + + if ( query.$endDate ) { + query.createdAt.$lte = new Date( query.$endDate ) + + delete query.$endDate; + } + } + delete query.$flatten const { $embed } = query if (query.$count) { diff --git a/node_modules/rest-hapi/utilities/joi-mongoose-helper.js b/node_modules/rest-hapi/utilities/joi-mongoose-helper.js index 1a076eb..e230021 100644 --- a/node_modules/rest-hapi/utilities/joi-mongoose-helper.js +++ b/node_modules/rest-hapi/utilities/joi-mongoose-helper.js @@ -337,6 +337,8 @@ internals.generateJoiListQueryModel = function(model, logger) { .optional() .description('An optional field for raw mongoose queries.') } + queryModel.$startDate = Joi.date().description( 'The start of the date range.' ).optional() + queryModel.$endDate = Joi.date().description( 'The end of the date range.' ).optional() _.each(queryableFields, function(fieldName) { const joiModel = internals.generateJoiModelFromFieldType(
This issue body was partially generated by patch-package.
The text was updated successfully, but these errors were encountered:
@alsabbahy thanks for this! I'll work on integrating this functionality into the tool.
Sorry, something went wrong.
No branches or pull requests
Hi @JKHeadley ! 👋
Firstly, thanks for your work on this project! 🙂
Regarding the issue #296.
Today I used patch-package to patch
[email protected]
for the project I'm working on.Here is the diff that solved my problem:
This issue body was partially generated by patch-package.
The text was updated successfully, but these errors were encountered: