Quickstart
To integrate cql into your project, you can head to the quickstart.
Run it
Refer to its README.md for running it.
Understand it
Once you have started your project with go init, you must add the dependency to cql:
go get -u github.com/FrancoLiberali/cql gorm.io/gorm
Create a package for your models, for example:
package models
import (
"github.com/FrancoLiberali/cql/model"
)
type MyModel struct {
model.UUIDModel
Name string
}
Once done, you can generate the conditions to perform queries on them. In this case, the file conditions/cql.go has the following content:
package conditions
//go:generate cql-gen ../models
Then, you can generate the conditions running:
go generate ./...
In main.go there is a main function that creates a gorm.DB that allows connection with the database and calls the AutoMigrate method with the models you want to be persisted.
After this, you are ready to query your objects using cql.Query.
Now that you know how to integrate cql into your project, you can learn how to use it by following the Tutorial.