Help us shape the future of Go! Take the 2026 Go Developer Survey

metadata

package
v0.26.1 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: Apache-2.0 Imports: 14 Imported by: 2

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var ErrSequenceReservationUnsupported = errors.New("atomic sequence reservation is unsupported")

ErrSequenceReservationUnsupported means the product has no atomic reservation owner.

Functions

This section is empty.

Types

type Service

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

Service represents metadata service

func New

func New() *Service

New creates new metadata service

func (*Service) DetectProduct

func (s *Service) DetectProduct(ctx context.Context, db *sql.DB, options ...option.Option) (*database.Product, error)

DetectProduct detect product for supplied *sql.DB

func (*Service) Execute

func (s *Service) Execute(ctx context.Context, db *sql.DB, kind info.Kind, options ...option.Option) (sql.Result, error)

Execute execute the metadata kind corresponding SQL

func (*Service) Info

func (s *Service) Info(ctx context.Context, db *sql.DB, kind info.Kind, sink Sink, options ...option.Option) error

Info execute the metadata kind corresponding Query, result are passed to sink

Example
package main

import (
	"context"
	"database/sql"
	"github.com/viant/sqlx/metadata"
	"github.com/viant/sqlx/metadata/info"
	"github.com/viant/sqlx/metadata/sink"
	"github.com/viant/sqlx/option"
	"log"
)

func main() {
	dsn := ""
	driver := ""
	db, err := sql.Open(driver, dsn)
	if err != nil {
		log.Fatalln(err)
	}

	meta := metadata.New()
	{
		tables := []sink.Table{}
		catalog := ""
		schema := "mydb"
		err := meta.Info(context.TODO(), db, info.KindTables, &tables, option.NewArgs(catalog, schema))
		if err != nil {
			log.Fatalln(err)
		}
		log.Println(tables)
	}

	{
		columnes := []sink.Column{}
		catalog := ""
		schema := "mydb"
		tables := "myTable"
		err := meta.Info(context.TODO(), db, info.KindTable, &columnes, option.NewArgs(catalog, schema, tables))
		if err != nil {
			log.Fatalln(err)
		}
		log.Println(columnes)
	}
}

type Sink

type Sink interface{}

Sink represents a meta data destination sink

Jump to

Keyboard shortcuts

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