-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
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
Update README.md #4
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,18 +15,64 @@ It's a package with some (currently two to be exact) tools to use when building | |
|
||
``` | ||
yarn add @entria/graphql-mongo-helpers | ||
|
||
or | ||
|
||
npm i @entria/graphql-mongo-helpers | ||
``` | ||
|
||
### Usage | ||
|
||
The most updated source of documentation are the test files, check the files in `src/__tests__/`. | ||
#### MATCH_1_TO_1 | ||
The example below includes use with or without regex, e sub field. | ||
``` | ||
const stringToRegexQuery = val => ({ $regex: new RegExp(val) }) | ||
|
||
const mapping = { | ||
code: { | ||
type: FILTER_CONDITION_TYPE.MATCH_1_TO_1, | ||
}, | ||
city: { | ||
type: FILTER_CONDITION_TYPE.MATCH_1_TO_1, | ||
format: stringToRegexQuery | ||
}, | ||
state: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we don't handle nested fields yet can you change? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, it would be interesting to say that too, |
||
uf: { | ||
type: FILTER_CONDITION_TYPE.MATCH_1_TO_1, | ||
key: 'state.uf' | ||
}, | ||
}, | ||
state: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. state { name } does not work it should be state {} or stateName { } |
||
name: { | ||
type: FILTER_CONDITION_TYPE.MATCH_1_TO_1, | ||
key: 'state.name' | ||
} | ||
}, | ||
} | ||
``` | ||
|
||
#### CUSTOM_CONDITION | ||
The custom condition can be used to filter posts that include a list of tag as in the example below: | ||
|
||
``` | ||
const mapping = { | ||
tags: { | ||
type: FILTER_CONDITION_TYPE.CUSTOM_CONDITION, | ||
format: tags => { | ||
if (!tags) return [] | ||
return { tags: { $in: tags } }; | ||
}, | ||
}, | ||
}; | ||
``` | ||
|
||
The following posts are going to have more info on both helpers currently exported by this library: | ||
#### AGGREGATE_PIPELINE | ||
Soon documentation will be included, As a complement to the documentation see all the tests, in `src/__tests__/`. | ||
|
||
[Introduction to GraphQL Mongo Helpers | ||
][post-a] | ||
### Posts: | ||
The following posts are going to have more info about use of this library: | ||
|
||
[Introduction to GraphQL Mongo Helpers][post-a] | ||
[Client-Supplied Custom Sorting Using GraphQL][post-b] | ||
|
||
[graphql]: https://github.com/graphql/graphql-js | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"e sub field" should be "and subfield"