Skip to content
This repository was archived by the owner on May 1, 2025. It is now read-only.

Commit 63eaa21

Browse files
author
Hans Kristian Flaatten
committed
Document custom query params
1 parent 24c49c2 commit 63eaa21

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

README.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ npm install mongo-querystring --save
3333
var MongoQS = require('mongo-querystring');
3434
```
3535

36-
### new MongoQS(`options`)
36+
### new MongoQS(`object` options)
3737

3838
* `Array` ops - list of supported operators
3939
* `object` alias - query param aliases
@@ -42,9 +42,24 @@ var MongoQS = require('mongo-querystring');
4242

4343
#### Custom query params
4444

45-
`TODO`
45+
Custom queries are on the folling form; you define the URL query parameter name
46+
that your users will be using and a function which takes the result query object
47+
and the value for query parameter.
4648

47-
### qs.parse(`params`)
49+
```javascript
50+
qs = new MongoQS({
51+
custom: {
52+
urlQueryParamName: function(query, input) {
53+
// do some processing of input value
54+
// add your queries to the query object
55+
query['someField'] = input;
56+
query['someOtherFiled'] = 'some value';
57+
}
58+
}
59+
});
60+
```
61+
62+
### qs.parse(`object` params)
4863

4964
Params is an object with URI query params and their values. Ex. `req.params`
5065
if you are working with ExpressJS.

0 commit comments

Comments
 (0)