You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+67-3Lines changed: 67 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,10 @@ Accept query parameters in express or similar libraries and convert them into sy
9
9
* Basic & Multiple-Column Sorting support. Query and sort your results by 1-or-more columns.
10
10
* Parses string input to integers, floats, booleans and dates.
11
11
* Accepts non-string values (though from express it will likely come through as a string type anyway).
12
+
* Allows specified DATETIME fields to be compared on the DATE-part only.
13
+
* Blacklisting.
14
+
* Aliasing.
15
+
* Custom handlers for specific column/query-key names.
12
16
13
17
### Operations
14
18
@@ -33,6 +37,59 @@ _You can see the configuration section to see how the operations can be configur
33
37
34
38
_**Note:** I use `[Op.gte]` & `[Op.lte]` instead of `[Op.between]` to handle dates and other types better. I will investigate if the latter is a better option._
35
39
40
+
### Aliasing & Blacklisting
41
+
By setting a column/property value into the Blacklist, you are telling the parser to simply ignore the key-value pair and not include it in the final output. With Aliasing, you can convert a specific incoming key-value pair to match the name of a known column. For example, converting incoming `personsAge=12` to `age=12`. Both of these can be configured in the initialise options.
42
+
43
+
```javascript
44
+
constsequelizeDateQS=newSequelizeQS({
45
+
blacklist: ['createdAt'],
46
+
alias: {
47
+
'personsAge':'age'
48
+
}
49
+
});
50
+
```
51
+
52
+
### Date Only
53
+
You can now easily (as of v1.1.0) have specific Date-type columns converted to compare on the Date only instead of including the Timestamp. DATEONLY fields in Sqlite are still working as they did before though!
54
+
55
+
To prevent breaking changes from prior versions and to also not rely on guess working with the code, you will need to specify what columns in your Sequelize model are actual Date columns you want to be handled in this way. You must also enable this feature by setting the `dateOnlyCompare` property in the options to `true`.
By default, `dateOnlyCompare` will be `false` and the initial array value for `dateFields` will contain the original timestamp columns that sequelize typically adds to your models by default (createdAt & updatedAt).
71
+
72
+
### Custom Handlers
73
+
A big improvement over the initial version is the ability to have the parser handle specific columns/query string properties in a specific way. This is configured through the initial options when setting up the parser.
74
+
75
+
Please note, that the value your custom function must return is one that would be interpreted by the Sequelize library. You can see an example below for more details;
This library contains some basics for parsing pagination and setting default values. There is checks in place to ensure no negative pages are set and also that not *too many* records are pulled down. The `default maximum page size is 100` but this can be configured in the options. You can also omit `page` and `limit` from the parameters and no paging will take place. Though, setting 1 or both will have an effect or enabling pagination.
You can pass additional configuration options into the constructor for the parser. This will change how the parser operations. **This is currently pretty experimental and does not have all the options available. You should be cautious with the order of operations otherwise you might get some unintended results!**
133
+
You can pass additional configuration options into the constructor for the parser. This will change how the parser operations. **As of Version 1.1, this have been a little more fleshed out. However, This is currently pretty experimental and does not have all the options available. You should be cautious with the order of operations otherwise you might get some unintended results!**
0 commit comments