go_orm

package module
v0.0.0-...-af973d3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 10, 2023 License: MIT Imports: 2 Imported by: 0

README

go_orm: A Minimalistic Go ORM Prototype

go_orm is an illustrative Object-Relational Mapping (ORM) package designed for Go. This ORM is generated using the Protocol Buffers (Protobuf) language, providing a mechanism to automatically create code from structured data definitions.

How It Works

  1. Protobuf Definitions: The base of this ORM is the link.proto file, which contains data structure definitions. The use of Protobuf ensures consistency and structured data definitions that can be easily serialized and transmitted over the wire.

  2. Code Generation: Using the protoc tool along with the protoc-gen-gotemplate plugin, we can generate Go code from the Protobuf definitions. The line //go:generate at the start of our go_orm package signifies this process.

  3. Data Access Object (DAO): The Store structure in our Go package serves as the DAO, allowing us to connect to a SQL database and execute queries.

  4. Dynamic Query Builder: The generated code provides a buildFilter function, which can construct SQL queries dynamically based on provided filters. This leverages the squirrel package, a fluent SQL query builder for Go.

Conclusion

This is a simple example of how we can leverage Protobuf to generate an ORM for Go.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Filter

type Filter struct {
	Pagination *Pagination
	Search     *StringFilterInput
	Field_mask *StringFilterInput
	Url        *StringFilterInput
	Hash       *StringFilterInput
	Describe   *StringFilterInput
	Created_at *StringFilterInput
	Updated_at *StringFilterInput
	Link       *StringFilterInput
}

func (*Filter) GetKeys

func (f *Filter) GetKeys() []string

GetKeys - return all keys

type Pagination

type Pagination struct {
	Page  int
	Limit int
}

type Store

type Store struct {
	// contains filtered or unexported fields
}

type StringFilterInput

type StringFilterInput struct {
	Eq          *string
	Ne          *string
	Lt          *string
	Le          *string
	Gt          *string
	Ge          *string
	Contains    *string
	NotContains *string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL