{"id":21031527,"url":"https://github.com/slaveofcode/restful-filter","last_synced_at":"2025-09-10T14:17:20.141Z","repository":{"id":92795751,"uuid":"107525601","full_name":"slaveofcode/restful-filter","owner":"slaveofcode","description":"Express library to convert querystring parameters into parsed json with related operators, also support pagination as well","archived":false,"fork":false,"pushed_at":"2018-03-14T03:37:44.000Z","size":33,"stargazers_count":10,"open_issues_count":2,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-15T11:39:23.592Z","etag":null,"topics":["filter","pagination","querystring","restful","restful-api"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/slaveofcode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-10-19T09:23:51.000Z","updated_at":"2021-04-21T23:50:08.000Z","dependencies_parsed_at":null,"dependency_job_id":"47bb725c-e876-45fa-a653-b1da46ed4c01","html_url":"https://github.com/slaveofcode/restful-filter","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/slaveofcode/restful-filter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slaveofcode%2Frestful-filter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slaveofcode%2Frestful-filter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slaveofcode%2Frestful-filter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slaveofcode%2Frestful-filter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/slaveofcode","download_url":"https://codeload.github.com/slaveofcode/restful-filter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slaveofcode%2Frestful-filter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274477055,"owners_count":25292778,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-10T02:00:12.551Z","response_time":83,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["filter","pagination","querystring","restful","restful-api"],"created_at":"2024-11-19T12:29:07.537Z","updated_at":"2025-09-10T14:17:20.133Z","avatar_url":"https://github.com/slaveofcode.png","language":"JavaScript","readme":"# Restful filter\n\nThis library aim to convert querystring parameters into parsed json with related operators, \nso you would able to use the parsed values into another query action like filtering by using your model on SQL library (knex, sequelize, etc).\n\n# Features\n - Filter querystring parameters\n - Parse pagination by using `page` and `count` parameter\n - Parse ordering by using `order` parameter\n\n## Installation\n\n    # via npm\n    npm i restful-filter --save\n\n    # via yarn\n    yarn add rest\n\n## Usage\n\n    const restfulFilter = require('restful-filter')\n\n    const filter = restfulFilter({ \n        case_sensitive: false // false by default, this is just example\n    })\n\n    # FILTER\n    # /api/users?name__ilike=aditya\u0026age__eq=25\u0026password__ilike=%a%\n    .get('/users', (req, res, next) =\u003e {\n      const queryParams = req.query\n      const allowedColumn = ['name', 'age']\n      const searchParams = filter.parse(queryParams, allowedColumn).filter\n\n      # now searchParams contains\n      # {\n      #   name: {operator: '$iLike', operatorSQL: 'ILIKE', column: 'name', value: 'aditya'},\n      #   age: {operator: '$eq', operatorSQL: '=', column: 'age', value: '25'}\n      # }\n      #\n      # password filter will not processed because not listed in the allowedColumn\n    })\n\n    # PAGINATION\n    # /api/users?page=2\n    .get('/users', (req, res, next) =\u003e {\n        const queryParams = req.query\n        const paginationParams = filter.parse(queryParams).paginate\n\n        # paginationParams contains\n        # {\n        #   offset: 20,\n        #   limit: 20   \n        # }\n    })\n\n    # ORDER\n    # api/users?order_by=-id,name\n    .get('/users', (req, res, next) =\u003e {\n        const queryParams = req.query\n        const orderParams = filter.parse(queryParams).order\n\n        # orderParams contains\n        # [\n        #   ['id', 'DESC']\n        #   ['name', 'ASC']\n        # ]\n\n        # You even can limit the order column value by using second parameter as allowedColumn to process\n        # Like \n        \n        const orderParams = filter.parse(queryParams, ['id']).order\n\n        # Would return\n        # [\n        #   ['id', 'DESC']\n        # ]\n    })\n\n    \n\n\n\n\n## Configuration\n  \n  Key | Default Value | Description\n  --- | --- | ---\n  `case_sensitive` | false | Use case sensitive on query string parameter and parameter value\n  `page_param_name` | `page` | Page parameter name to be used on querystring\n  `limit_param_name` | `count` | Limit parameter name to be used on querystring\n  `per_page` | 20 | Default number count per request if not set\n  `max_count_per_page` | 100 | Maximum count for `per_page` parameter, so for example if `count` parameter value is higher than 100, the return value would stick to 100\n  `order_param_name` | `order_by` | Order parameter name to be used on querystring\n\n## Operators\n\n  Operator | Description | Example\n  --- | --- | ---\n  `__eq` | Find column equal with value | `?name__eq=smith`\n  `__not` | Not same with given value | `?active__not=true`\n  `__ne` | Negation, the opposite of equal | `?name__ne=smith`\n  `__lt` | Lower than | `?age__lt=10`\n  `__gt` | Greater than | `?age__gt=15`\n  `__lte` | Lower than and equal | `?age__lte=25`\n  `__gte` | Greater than and equal | `?age__gte=20`\n  `__like` | Like with case sensitive | `?name__like=smith`\n  `__ilike` | Like with case insensitive (Postgres) | `?name__ilike=smith`\n  `__notLike` | Opposite of like with case sensitive | `?name__notLike=smith`\n  `__notILike` | Opposite of like with case insensitive (Postgres) | `?name__notILike=smith`\n  `__in` | Find value which listed on given list | `?city__in=jakarta,bandung,bekasi`\n  `__notIn` | Find value which not listed in given list | `?city__notIn=bogor,depok,tangerang`\n  `__contains` | Find value that contains in given list (Postgres) | `?name__contains=smith`\n  `__between` | Find value which between 2 given values | `?date__between=2015-06-18,2017-05-31`\n  `__notBetween` | Find value which is not between 2 given values | `?date__notBetween=2015-06-18,2017-05-31`\n\n## Test\n\n    npm run test\n\n# Note\nPlease open a pull request for further abilities and another issues\n\n## License\nMIT\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslaveofcode%2Frestful-filter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fslaveofcode%2Frestful-filter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslaveofcode%2Frestful-filter/lists"}