Created
December 19, 2019 20:07
-
-
Save tyrw/c7d5b60f56a04fadcb9a9baa89eb3c10 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// As stored in state variable | |
facets = { | |
operator: 'AND', | |
filterGroups: [ | |
{ | |
operator: 'AND', | |
filters: [ | |
{ | |
attribute: 'name', | |
comparator: '$iLike', | |
value: 'John' | |
}, | |
{ | |
attribute: 'lastActiveAt', | |
comparator: '$between', | |
value: ['Thu Dec 12 2019 11:59:27 GMT-0800', 'Thu Dec 19 2019 11:59:27 GMT-0800'] | |
} | |
] | |
}, | |
{ | |
operator: 'AND', | |
filters: [ | |
{ | |
attribute: 'userId', | |
comparator: '$gte', | |
value: 20 | |
} | |
] | |
} | |
] | |
} | |
// Function to convert facets into query | |
fn(facets) | |
=> | |
{ | |
$and: [ | |
$and: [ | |
name: { $iLike: 'John' }, | |
lastActiveAt: { $between: ['Thu Dec 12 2019 11:59:27 GMT-0800', 'Thu Dec 19 2019 11:59:27 GMT-0800'] } | |
], | |
$and: [ | |
userId: { $gte: 20 } | |
] | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment