Skip to content
Node: knexgithub.com/sahilkhaire/gox/db

Query

Overview ​

Query is a chainable SELECT builder.

Part of the db package — Node.js analog: knex.

Query is a type exported by gox. Methods on this type are documented separately.

Signature ​

go
type Query struct {
	// contains filtered or unexported fields
}

Compare: Node.js · Standard Go · gox ​

js
// Typical knex pattern in Node.js
go
db, err := sqlx.Connect("postgres", dsn)
db.GetContext(ctx, &row, query, args...)
go
import "github.com/sahilkhaire/gox/db"

q := db.From("users").Select("id", "email").WhereEq("active", true)

Example ​

go
import "github.com/sahilkhaire/gox/db"

q := db.From("users").Select("id", "email").WhereEq("active", true)

Tips ​

Pass context.Context as the first argument so cancellation and deadlines propagate correctly.

Standard library alternative ​

Use the standard library directly:

go
db, err := sqlx.Connect("postgres", dsn)
db.GetContext(ctx, &row, query, args...)

← Back to db package overview

MIT Licensed · Built for Node.js developers moving to Go