Skip to content

Commit b3be4c5

Browse files
author
Lucas Cosmo Rocha
committed
Update README.md
Adding search table content.
1 parent 0750c92 commit b3be4c5

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

README.md

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -137,19 +137,23 @@ app.use(qs({
137137
#### 3.5 Data
138138
| Query | Description | Result |
139139
| ------ | ------ | ------ |
140-
| `?start_at=2018-11-10&end_at=2018-12-10` | Search where the user wants results between 2018-12-10 and 2018-12-12. | `{ filters: { $and: [ { created_at: { $lt: '2018-12-10T00:00:00.000Z' } }, { created_at: { $gte: '2018-11-10T00:00:00.000Z' } } ] } }` |
141-
| `?start_at=2018-12-10` | Search where the user wants results between 2018-12-10 and the current date. In this example, the current day is: 2018-12-12. | `{ filters: { $and: [ { created_at: { $lt: '2018-12-13T00:00:00.000Z' } }, { created_at: { $gte: '2018-12-10T00:00:00.000Z' } } ] } }` |
142-
| `?end_at=2018-12-11&period=10d` | Search where the user wants results from 10 days before 2018-12-12. | `{ filters: { $and: [ { created_at: { $lt: '2018-12-11T00:00:00.000Z' } }, { created_at: { $gte: '2018-11-30T00:00:00.000Z' } } ] } }` |
143-
| `?period=10d` | Search where the user wants results from 10 days before the current date. In this example, the current day is: 2018-12-12. | `{ filters: { $and: [ { created_at: { $lt: '2018-12-13T00:00:00.000Z' } }, { created_at: { $gte: '2018-12-02T00:00:00.000Z' } } ] } }` |
144-
| `?end_at=2018-12-11&period=8w` | Search where the user wants results from 8 weeks before 2018-12-12. | `{ filters: { $and: [ { created_at: { $lt: '2018-12-11T00:00:00.000Z' } }, { created_at: { $gte: '2018-10-15T00:00:00.000Z' } } ] } }` |
145-
| `?period=8w` | Search where the user wants results from 8 weeks before the current date. In this example, the current day is: 2018-12-12. | `{ filters: { $and: [ { created_at: { $lt: '2018-12-13T00:00:00.000Z' } }, { created_at: { $gte: '2018-10-17T00:00:00.000Z' } } ] } }` |
146-
| `?end_at=2018-12-11&period=6m` | Search where the user wants results from 6 months before 2018-12-11. | `{ filters: { $and: [ { created_at: { $lt: '2018-12-11T00:00:00.000Z' } }, { created_at: { $gte: '2018-06-10T03:00:00.000Z' } } ] } }` |
147-
| `?period=6m` | Search where the user wants results from 6 months before the current date. In this example, the current day is: 2018-12-12. | `{ filters: { $and: [ { created_at: { $lt: '2018-12-13T00:00:00.000Z' } }, { created_at: { $gte: '2018-06-12T03:00:00.000Z' } } ] } }` |
148-
| `?end_at=2018-12-11&period=4y` | Search where the user wants results from 4 years before 2018-12-11. | `{ filters: { $and: [ { created_at: { $lt: '2018-12-11T00:00:00.000Z' } }, { created_at: { $gte: '2014-12-10T00:00:00.000Z' } } ] } }` |
149-
| `?period=4y` | Search where the user wants results from 4 years before the current date. In this example, the current day is: 2018-12-12. | `{ filters: { $and: [ { created_at: { $lt: '2018-12-13T00:00:00.000Z' } }, { created_at: { $gte: '2014-12-12T00:00:00.000Z' } } ] } }` |
140+
| `?start_at=2018-11-10&end_at=2018-12-10` | Search where the user wants results between 2018-12-10 and 2018-12-12. | `{ filters: { $and: [ { created_at: { $lt: '2018-12-10T23:59:59' } }, { created_at: { $gte: '2018-11-10T00:00:00' } } ] } }` |
141+
| `?start_at=2018-12-10` | Search where the user wants results between 2018-12-10 and the current date. In this example, the current day is: 2018-12-12. | `{ filters: { $and: [ { created_at: { $lt: '2018-12-13T23:59:59' } }, { created_at: { $gte: '2018-12-10T00:00:00' } } ] } }` |
142+
| `?end_at=2018-12-11&period=10d` | Search where the user wants results from 10 days before 2018-12-12. | `{ filters: { $and: [ { created_at: { $lt: '2018-12-11T23:59:59' } }, { created_at: { $gte: '2018-11-30T00:00:00' } } ] } }` |
143+
| `?period=10d` | Search where the user wants results from 10 days before the current date. In this example, the current day is: 2018-12-12. | `{ filters: { $and: [ { created_at: { $lt: '2018-12-13T23:59:59' } }, { created_at: { $gte: '2018-12-02T00:00:00' } } ] } }` |
144+
| `?end_at=2018-12-11&period=8w` | Search where the user wants results from 8 weeks before 2018-12-12. | `{ filters: { $and: [ { created_at: { $lt: '2018-12-11T23:59:59' } }, { created_at: { $gte: '2018-10-15T00:00:00' } } ] } }` |
145+
| `?period=8w` | Search where the user wants results from 8 weeks before the current date. In this example, the current day is: 2018-12-12. | `{ filters: { $and: [ { created_at: { $lt: '2018-12-13T23:59:59' } }, { created_at: { $gte: '2018-10-17T00:00:00' } } ] } }` |
146+
| `?end_at=2018-12-11&period=6m` | Search where the user wants results from 6 months before 2018-12-11. | `{ filters: { $and: [ { created_at: { $lt: '2018-12-11T23:59:59' } }, { created_at: { $gte: '2018-06-10T00:00:00' } } ] } }` |
147+
| `?period=6m` | Search where the user wants results from 6 months before the current date. In this example, the current day is: 2018-12-12. | `{ filters: { $and: [ { created_at: { $lt: '2018-12-13T23:59:59' } }, { created_at: { $gte: '2018-06-12T00:00:00' } } ] } }` |
148+
| `?end_at=2018-12-11&period=4y` | Search where the user wants results from 4 years before 2018-12-11. | `{ filters: { $and: [ { created_at: { $lt: '2018-12-11T23:59:59' } }, { created_at: { $gte: '2014-12-10T00:00:00' } } ] } }` |
149+
| `?period=4y` | Search where the user wants results from 4 years before the current date. In this example, the current day is: 2018-12-12. | `{ filters: { $and: [ { created_at: { $lt: '2018-12-13T23:59:59' } }, { created_at: { $gte: '2014-12-12T00:00:00' } } ] } }` |
150150

151151
#### 3.6 Search
152-
// TODO
152+
| Query | Description | Result |
153+
| ------ | ------ | ------ |
154+
| `?name=elvis*`| Search where the user want results that the name starts with value 'elvis'. | `{ filters: { name: { '$options': 'i', '$regex': '^lucas' } } ` |
155+
| `?name=*elvis` | Search where the user want results that the name ends with the value 'elvis'. | `{ filters: { name: { '$options': 'i', '$regex': 'lucas&' } } ` |
156+
| `?name=*elvis*` | Search where the user wants results for name that contains the value 'elvis' in any position. | `{ filters: { name: { '$options': 'i', '$regex': 'lucas' } } ` |
153157

154158
**NOTES** :
155159
* Default values are used only when they are not passed in the query string. For example, if you set the default value `?sort=-age` _(age in descending order)_ and your client makes a request with `?sort=name` _(name in ascending order)_, you will get in req.query the value `{ sort: { name: 'asc' } }`, since the values passed by the client will always have preference.

test/integration/index.spec.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ describe('queryFilter()', function () {
240240
const expect_filters = {
241241
$and: [
242242
{ created_at: { $lt: new Date().toISOString() } },
243-
{ created_at: { $gte: '2018-12-05T00:00:00.000Z' } }
243+
{ created_at: { $gte: '2018-12-05T00:00:00' } }
244244
]
245245
}
246246

@@ -261,7 +261,7 @@ describe('queryFilter()', function () {
261261
const expect_filters = {
262262
$and: [
263263
{ created_at: { $lt: new Date().toISOString() } },
264-
{ created_at: { $gte: '2018-12-05T00:00:00.000Z' } }
264+
{ created_at: { $gte: '2018-12-05T00:00:00' } }
265265
]
266266
}
267267

@@ -282,8 +282,8 @@ describe('queryFilter()', function () {
282282

283283
const expect_filters = {
284284
$and: [
285-
{ created_at: { $lt: '2018-12-11T00:00:00.000Z' } },
286-
{ created_at: { $gte: '2018-12-01T00:00:00.000Z' } }]
285+
{ created_at: { $lt: '2018-12-11T00:00:00' } },
286+
{ created_at: { $gte: '2018-12-01T00:00:00' } }]
287287
}
288288

289289
const query = { start_at: '2018-12-01', end_at: '2018-12-11' }
@@ -303,8 +303,8 @@ describe('queryFilter()', function () {
303303

304304
const expect_filters = {
305305
$and: [
306-
{ created_at: { $lt: '2018-12-11T00:00:00.000Z' } },
307-
{ created_at: { $gte: '2018-12-01T00:00:00.000Z' } }]
306+
{ created_at: { $lt: '2018-12-11T00:00:00' } },
307+
{ created_at: { $gte: '2018-12-01T00:00:00' } }]
308308
}
309309

310310
const query = { start_at: '2018-12-01T00:00:00', end_at: '2018-12-11T00:00:00' }

0 commit comments

Comments
 (0)