nocodb

package
v0.97.8 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package nocodb implements the NocoDB provider.

Index

Constants

View Source
const (
	ID          = "nocodb"
	EndpointKey = "endpoint"
	TokenKey    = "token"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Base

type Base struct {
	ID    string `json:"id"`
	Title string `json:"title"`
}

Base is a NocoDB project/base.

type BaseList

type BaseList struct {
	List     []Base   `json:"list"`
	PageInfo PageInfo `json:"pageInfo"`
}

BaseList is the envelope returned by list bases.

type Column

type Column struct {
	ID         string `json:"id"`
	Title      string `json:"title"`
	UIDT       string `json:"uidt"`
	ColumnName string `json:"column_name"`
}

Column is a table column definition.

type ListRecordsQuery

type ListRecordsQuery struct {
	Limit  int
	Offset int
	Where  string
	Sort   string
	Fields string
}

ListRecordsQuery holds optional query parameters for listing records.

type NocoDB

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

NocoDB is an HTTP client for the NocoDB v2 Data and Meta APIs.

func GetClient

func GetClient() *NocoDB

GetClient builds a NocoDB client from vendors.nocodb config. Returns nil when endpoint is not configured.

func NewNocoDB

func NewNocoDB(endpoint, token string) *NocoDB

NewNocoDB creates a NocoDB client with the given endpoint and API token. Authentication uses the xc-token header. Returns nil when endpoint is empty.

func (*NocoDB) CreateRecord

func (n *NocoDB) CreateRecord(ctx context.Context, tableID string, fields map[string]any) (Record, error)

CreateRecord creates a record with the given field values.

func (*NocoDB) DeleteRecord

func (n *NocoDB) DeleteRecord(ctx context.Context, tableID, id string) error

DeleteRecord deletes a record by ID. Numeric record IDs are sent as JSON numbers to match the NocoDB v2 contract.

func (*NocoDB) GetRecord

func (n *NocoDB) GetRecord(ctx context.Context, tableID, recordID string) (Record, error)

GetRecord returns a single record by ID.

func (*NocoDB) GetTable

func (n *NocoDB) GetTable(ctx context.Context, tableID string) (*Table, error)

GetTable returns table metadata including columns.

func (*NocoDB) ListBases

func (n *NocoDB) ListBases(ctx context.Context) (*BaseList, error)

ListBases returns all bases visible to the API token (first page).

func (*NocoDB) ListRecords

func (n *NocoDB) ListRecords(ctx context.Context, tableID string, q ListRecordsQuery) (*RecordList, error)

ListRecords returns records for a table with optional filters.

func (*NocoDB) ListTables

func (n *NocoDB) ListTables(ctx context.Context, baseID string) (*TableList, error)

ListTables returns tables belonging to the given base (first page).

func (*NocoDB) UpdateRecord

func (n *NocoDB) UpdateRecord(ctx context.Context, tableID string, fields map[string]any) (Record, error)

UpdateRecord updates a record identified by Id in fields. Numeric record IDs are sent as JSON numbers to match the NocoDB v2 contract.

type PageInfo

type PageInfo struct {
	TotalRows   int  `json:"totalRows"`
	Page        int  `json:"page"`
	PageSize    int  `json:"pageSize"`
	IsFirstPage bool `json:"isFirstPage"`
	IsLastPage  bool `json:"isLastPage"`
}

PageInfo holds NocoDB list pagination metadata.

type Record

type Record map[string]any

Record is a single table row. Field keys are column titles; Id is the primary key.

type RecordList

type RecordList struct {
	List     []Record `json:"list"`
	PageInfo PageInfo `json:"pageInfo"`
}

RecordList is the envelope returned by list records.

type StatusError

type StatusError struct {
	Op     string
	Status int
	Msg    string
}

StatusError is returned when NocoDB responds with a non-2xx status.

func AsStatusError

func AsStatusError(err error) (*StatusError, bool)

AsStatusError extracts a StatusError from err if present.

func (*StatusError) Error

func (e *StatusError) Error() string

Error implements the error interface.

type Table

type Table struct {
	ID      string   `json:"id"`
	Title   string   `json:"title"`
	BaseID  string   `json:"base_id"`
	Columns []Column `json:"columns"`
}

Table is a NocoDB table with optional columns.

type TableList

type TableList struct {
	List     []Table  `json:"list"`
	PageInfo PageInfo `json:"pageInfo"`
}

TableList is the envelope returned by list tables.

Jump to

Keyboard shortcuts

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