adapter

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package adapter provides query-building adapters that translate filter.Options into database-specific queries.

Two adapters are available:

SQL via goqu

GoquQuery takes an filter.Options and a *goqu.SelectDataset and returns a new dataset with WHERE clauses and ORDER BY applied:

dataset, err := adapter.GoquQuery(ctx, opts, goqu.From("users").Select("*"))

MongoDB

MongoQueryD takes filter.Options and returns a bson.D filter together with *options.FindOptions that include limit, skip (pagination), and sort:

bsonFilter, findOpts, err := adapter.MongoQueryD(ctx, opts)
cursor, err := collection.Find(ctx, bsonFilter, findOpts)

Both adapters accept a context.Context as the first argument.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GoquQuery

func GoquQuery(ctx context.Context, op filter.Options, dataset *goqu.SelectDataset) (*goqu.SelectDataset, error)

GoquQuery builds a goqu.SelectDataset with filters, sorting and context applied.

func MongoQueryD

func MongoQueryD(ctx context.Context, op filter.Options) (bson.D, *options.FindOptions, error)

MongoQueryD builds a bson.D filter and FindOptions from filter.Options. The ctx parameter should be used by the caller when executing the query.

Types

This section is empty.

Jump to

Keyboard shortcuts

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