{"id":16807650,"url":"https://github.com/borsch/rsql-mongodb","last_synced_at":"2025-06-26T03:33:33.649Z","repository":{"id":120033043,"uuid":"287365449","full_name":"borsch/rsql-mongodb","owner":"borsch","description":null,"archived":false,"fork":false,"pushed_at":"2020-08-21T15:42:41.000Z","size":53,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-18T05:32:08.269Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/borsch.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2020-08-13T19:38:22.000Z","updated_at":"2023-07-20T12:17:02.000Z","dependencies_parsed_at":null,"dependency_job_id":"6b7b6068-1faa-4803-a790-bcabac170a57","html_url":"https://github.com/borsch/rsql-mongodb","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/borsch/rsql-mongodb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/borsch%2Frsql-mongodb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/borsch%2Frsql-mongodb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/borsch%2Frsql-mongodb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/borsch%2Frsql-mongodb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/borsch","download_url":"https://codeload.github.com/borsch/rsql-mongodb/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/borsch%2Frsql-mongodb/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261994611,"owners_count":23242044,"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","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":[],"created_at":"2024-10-13T09:54:22.567Z","updated_at":"2025-06-26T03:33:33.620Z","avatar_url":"https://github.com/borsch.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Defunct\nThis library has been superseded by the more general (and just better) [rest-query-engine](https://github.com/rutledgepaulv/rest-query-engine).\n\n\n![Java CI with Maven](https://github.com/borsch/rsql-mongodb/workflows/Java%20CI%20with%20Maven/badge.svg?branch=master)\n\n### What\n\nAn open source implementation for converting [rsql](https://github.com/jirutka/rsql-parser) to mongo queries for spring\ndata. RSQL is a flexible and readable query language based off of apache's FIQL. Providing this adapater for mongo queries\nmakes RSQL a natural choice for APIs that want to provide flexible querying and whose underlying datastore is mongodb.\n\n\n### How to use it\n\nAdd maven dependency\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.github.borsch\u003c/groupId\u003e\n    \u003cartifactId\u003ersql-mongodb\u003c/artifactId\u003e\n    \u003cversion\u003e1.1\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n```java\n\n@Autowired\nprivate MongoOperations mongoOperations;\n\n@Autowired\nprivate MongoMappingContext mappingContext;\n\n// build the converter. You can define a list of conversions instead, but using a spring conversion service and mongo mapping context\n// works really quite well. Some applications will have a conversion service available from the application context that can include\n// custom converters (iso -\u003e date, etc)\nComparisonToCriteriaConverter converter = new ComparisonToCriteriaConverter(new DefaultConversionService(), mongoMappingContext);\n\n// build the actual rsql string -\u003e mongo criteria adapter\nRsqlMongoAdapter adapter = new RsqlMongoAdapter(converter);\n\n// convert the rsql to some criteria and add that criteria to the mongo query object\nQuery query = Query.query(adapter.getCriteria(\"firstName==joe\", Person.class));\n\n// make your query!\nList\u003cPerson\u003e personsNamedJoe = mongoOperations.find(query, Person.class);\n\n```\n\n\n### Examples of supported cases. For the full list, please see tests.\n\n```\n# basic equality\nfirstName==joe -\u003e { \"firstName\" : \"joe\"}\n\n# basic inequality\nfirstName!=joe -\u003e { \"firstName\" : { \"$ne\" : \"joe\"}}\n\n# basic greater than\ncreateDate=gt=300 -\u003e { \"createDate\" : { \"$gt\" : 300}}\n\n# basic greater than or equal\ncreateDate=ge=300 -\u003e { \"createDate\" : { \"$gte\" : 300}}\n\n# basic less than\ncreateDate=lt=300 -\u003e { \"createDate\" : { \"$lt\" : 300}}\n\n# basic less than or equal\ncreateDate=le=300 -\u003e { \"createDate\" : { \"$lte\" : 300}}\n\n# basic element appears in list\nfirstName=in=(billy,bob,joel) -\u003e { \"firstName\" : { \"$in\" : [ \"billy\" , \"bob\" , \"joel\"]}}\n\n# basic element does not appear in list\nfirstName=out=(billy,bob,joel) -\u003e { \"firstName\" : { \"$nin\" : [ \"billy\" , \"bob\" , \"joel\"]}}\n\n# anding of two basic conditions\nfirstName!=joe;lastName==dummy -\u003e { \"$and\" : [ { \"firstName\" : { \"$ne\" : \"joe\"}} , { \"lastName\" : \"dummy\"}]}\n\n# oring of two basic conditions\nfirstName!=john,lastName==doe -\u003e { \"$or\" : [ { \"firstName\" : { \"$ne\" : \"john\"}} , { \"lastName\" : \"doe\"}]}\n\n# anding of two oring conditions of anding conditions\n((firstName==john;lastName==doe),(firstName==aaron;lastName==carter));((age==21;height==90),(age==30;height==100)) -\u003e \n\n    {\n       \"$and\":[\n          {\n             \"$or\":[\n                {\n                   \"$and\":[\n                      {\n                         \"firstName\":\"john\"\n                      },\n                      {\n                         \"lastName\":\"doe\"\n                      }\n                   ]\n                },\n                {\n                   \"$and\":[\n                      {\n                         \"firstName\":\"aaron\"\n                      },\n                      {\n                         \"lastName\":\"carter\"\n                      }\n                   ]\n                }\n             ]\n          },\n          {\n             \"$or\":[\n                {\n                   \"$and\":[\n                      {\n                         \"age\":21\n                      },\n                      {\n                         \"height\":90\n                      }\n                   ]\n                },\n                {\n                   \"$and\":[\n                      {\n                         \"age\":30\n                      },\n                      {\n                         \"height\":100\n                      }\n                   ]\n                }\n             ]\n          }\n       ]\n    }\n    \n```\n\n\n### License\n\nThis project is licensed under [MIT license](http://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fborsch%2Frsql-mongodb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fborsch%2Frsql-mongodb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fborsch%2Frsql-mongodb/lists"}