A Go library that translates MongoDB-like JSON queries into SQL WHERE clauses for REST APIs.
RQL (Resource Query Language) is a Go library that provides a simple, lightweight API for adding dynamic querying capabilities to web applications using SQL-based databases. It acts as a connector between HTTP handlers and database engines, handling validation and translation of user inputs into safe SQL queries.
Go developers building RESTful web applications with SQL databases who need to expose flexible, dynamic querying APIs to frontend clients. It is particularly useful for projects using ORMs like GORM, Ent, XORM, or go-pg.
Developers choose RQL because it offers a standardized, MongoDB-like query syntax for SQL databases, eliminating ad-hoc query string parameters and ensuring type-safe, validated database interactions. Its database-agnostic design and simple struct tag configuration make it easy to integrate with existing Go projects.
Resource Query Language for REST
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Uses a familiar subset of MongoDB query syntax for filtering, sorting, and pagination, making it easy for developers accustomed to NoSQL interfaces to adopt, as highlighted in the Motivation section.
Allows quick setup by adding `rql` tags to Go structs (e.g., `rql:"filter,sort"`), enabling automatic validation and translation without extensive boilerplate code, as shown in the Getting Started example.
Converts JSON queries into SQL with placeholders for WHERE, ORDER BY, LIMIT, and OFFSET clauses, preventing SQL injection and ensuring type-safe database interactions, evidenced by the FilterExp and FilterArgs output in examples.
Works seamlessly with popular Go ORMs like GORM, Ent, XORM, and go-pg, providing flexibility in database choice, as demonstrated in the API examples section.
Assumes all fields are flat in the database, making it challenging to handle complex nested structs or joins without manual workarounds, as admitted in the Future Plans section for adding table options.
Lacks logical operators like $not and $nor, which are listed as future enhancements, limiting query expressiveness for some use cases compared to full MongoDB syntax.
Uses reflection during parser initialization for type validation, which can introduce minor performance overhead in startup or dynamic scenarios, though it's a one-time cost as noted in the API documentation.