Introduction

GoooQo is a database access framework implemented in Go, based on OQM techniques. It relies entirely on objects to construct various database query statements, eliminating boilerplate code associated with traditional ORM frameworks, and assists developers in achieving automated database access operations.

The first three Os in the name GoooQo stands for the three major object concepts in OQM:

  • Entity Object is used to map the static part in the SQL statements, such as the table name and column names;

  • Query Object is used to map the dynamic part of the SQL statements, such as filter conditions, pagination, and sorting;

  • View Object is used to map the static part in complex query statements, such as table names, column names, nested views, and the GROUP BY clause.

The Dynamic Combination of Query Conditions ​

A query interface with n query conditions can generate 2^n unique query requests by combining different parameter values to construct corresponding query statements.

Similarly, an object with n fields has 2^n different assignment combinations.

The 2^n assignment combinations of object instances are mapped exactly to 2^n combinations of query conditions.

OQM technology leverages this relationship and introduces the query object mapping method, where each field of the query object corresponds to a query condition, and query clauses are constructed based on field assignments.

In this way, the logic of building query clauses can be separated from the logic of constructing query parameters and encapsulated as common functions in a framework, allowing developers to focus solely on the definition and assignment of query objects.

The Definition of the Query​ Object

A basic query condition consists of a column name, a comparison operator, and a value. The fields in the entity correspond to the column names. When we use aliases to represent comparison operators and combine them with the fields in an entity object as suffixes, we get the fields of the query object. Therefore, we have the following formula:

Entity+Suffix=QueryEntity + Suffix = Query

Here is an example:

Entity + Suffix = Query

Community

Gitter: https://gitter.im/doytowin/goooqo

Discussion: https://github.com/doytowin/goooqo/discussions

Last updated

Was this helpful?