nosqlite

package module
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: May 6, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Clause

type Clause interface {
	// Clause returns the clause as a string using parameters for values
	Clause() string
	// Values returns the values to assign to the parameters in the clause
	Values() []any

	And(c Clause) Clause
	Or(c Clause) Clause
}

Clause represents a clause in a query

func And

func And(clauses ...Clause) Clause

And returns a clause that combines clauses with an AND operator

func Between

func Between[T string | number](field string, from, to T) Clause

Between returns a clause that checks if a field is between two values

func Contains added in v0.2.0

func Contains[T string | number](field string, value T) Clause

Contains returns a clause that checks if a list field contains a single value

func ContainsAll added in v0.2.0

func ContainsAll[T string | number](field string, values ...T) Clause

func ContainsAny added in v0.2.0

func ContainsAny[T string | number](field string, values ...T) Clause

func Equal

func Equal[T string | number](field string, value T) Clause

Equal returns a clause that checks if a field is equal to a value

func GreaterThan

func GreaterThan[T string | number](field string, value T) Clause

GreaterThan returns a clause that checks if a field is greater than a value

func GreaterThanOrEqual

func GreaterThanOrEqual[T string | number](field string, value T) Clause

GreaterThanOrEqual returns a clause that checks if a field is greater than or equal to a value

func In

func In(field string, values ...any) Clause

In returns a clause that checks if a field is in a list of values

func LessThan

func LessThan[T string | number](field string, value T) Clause

LessThan returns a clause that checks if a field is less than a value

func LessThanOrEqual

func LessThanOrEqual[T string | number](field string, value T) Clause

LessThanOrEqual returns a clause that checks if a field is less than or equal to a value

func Like

func Like(field string, value string) Clause

Like returns a clause that checks if a field is like a value It's up to the user to add the requisite % characters

func NotEqual

func NotEqual[T string | number](field string, value T) Clause

NotEqual returns a clause that checks if a field is not equal to a value

func Or

func Or(clauses ...Clause) Clause

Or returns a clause that combines clauses with an OR operator

type Store

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

Store represents a store for the database

func NewStore

func NewStore(filePath string) (*Store, error)

NewStore creates a new store with the given file path

func NewStoreWithDB

func NewStoreWithDB(db *sql.DB) (*Store, error)

NewStoreWithDB creates a new store with the given database

func (*Store) Close

func (s *Store) Close() error

Close closes the database

func (*Store) Ping added in v0.2.0

func (s *Store) Ping() error

type Table

type Table[T any] struct {

	// Name of the table
	Name string
	// contains filtered or unexported fields
}

Table represents a table in the database

func NewTable

func NewTable[T any](ctx context.Context, store *Store) (*Table[T], error)

NewTable creates a new table with the given type T

func (*Table[T]) Count

func (n *Table[T]) Count(ctx context.Context) (uint64, error)

Count returns the number of items in the table

func (*Table[T]) CreateIndex

func (n *Table[T]) CreateIndex(ctx context.Context, fields ...string) (string, error)

CreateIndex creates an index on the given fields

func (*Table[T]) CreateIndexes added in v0.3.0

func (n *Table[T]) CreateIndexes(ctx context.Context, indexes ...[]string) ([]string, error)

func (*Table[T]) CreateTable

func (n *Table[T]) CreateTable(ctx context.Context) error

CreateTable creates the table if it does not exist

func (*Table[T]) Delete

func (n *Table[T]) Delete(ctx context.Context, clause Clause) error

Delete removes items from the table that match the given clause

func (*Table[T]) Insert

func (n *Table[T]) Insert(ctx context.Context, data T) error

Insert adds a new item to the table

func (*Table[T]) QueryMany

func (n *Table[T]) QueryMany(ctx context.Context, clause Clause) ([]T, error)

QueryMany returns multiple items from the table can we use http://doug-martin.github.io/goqu/ for this?

func (*Table[T]) QueryOne

func (n *Table[T]) QueryOne(ctx context.Context, clause Clause) (*T, error)

QueryOne returns a single item from the table

func (*Table[T]) Update

func (n *Table[T]) Update(ctx context.Context, clause Clause, newVal T) error

Update changes one or more items in the table

Jump to

Keyboard shortcuts

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