table

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ListOptions

type ListOptions struct {
	Query                    string                   // sysparm_query (use QueryBuilder.Build())
	Fields                   []string                 // sysparm_fields (comma-separated)
	Limit                    int                      // sysparm_limit
	Offset                   int                      // sysparm_offset
	DisplayValue             core.DisplayValueOptions // sysparm_display_value
	ExcludeReferenceLink     bool                     // sysparm_exclude_reference_link = true
	View                     string                   // sysparm_view
	NoCount                  bool                     // sysparm_no_count = true
	SuppressPaginationHeader bool                     // sysparm_suppress_pagination_header = true

}

ListOptions for common sysparm params

type Logical

type Logical string

Logical defines logical connectors

const (
	And Logical = "^"   // AND
	Or  Logical = "^OR" // OR
	NQ  Logical = "^NQ" // NOT (negate query)
)

type Operator

type Operator string

Operator defines supported query operators

const (
	Eq         Operator = "="          // Equals
	NotEq      Operator = "!="         // Not equals
	Gt         Operator = ">"          // Greater than
	Lt         Operator = "<"          // Less than
	Gte        Operator = ">="         // Greater than or equals
	Lte        Operator = "<="         // Less than or equals
	Like       Operator = "LIKE"       // Contains substring
	NotLike    Operator = "NOTLIKE"    // Does not contain
	StartsWith Operator = "STARTSWITH" // Starts with
	EndsWith   Operator = "ENDSWITH"   // Ends with
	Contains   Operator = "CONTAINS"   // Contains (alias for LIKE with %)
	In         Operator = "IN"         // In list (comma-separated)
	NotIn      Operator = "NOTIN"      // Not in list
	IsEmpty    Operator = "ISEMPTY"    // Is empty
	IsNotEmpty Operator = "ISNOTEMPTY" // Is not empty
	Between    Operator = "BETWEEN"    // Between two values (e.g., "1@5")
	SameAs     Operator = "SAMEAS"     // Same as another field
	NotSameAs  Operator = "NSAMEAS"    // Not same as
)

type QueryBuilder

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

QueryBuilder builds encoded sysparm_query strings

func NewQueryBuilder

func NewQueryBuilder() *QueryBuilder

NewQueryBuilder creates a new builder

func (*QueryBuilder) Add

func (qb *QueryBuilder) Add(logical Logical, field string, op Operator, value interface{}) *QueryBuilder

Add adds a field-operator-value clause with a logical connector

func (*QueryBuilder) And

func (qb *QueryBuilder) And(field string, op Operator, value interface{}) *QueryBuilder

And is a shortcut for Add with And logical

func (*QueryBuilder) Build

func (qb *QueryBuilder) Build() (string, error)

Build constructs the encoded query string

func (*QueryBuilder) GroupBy

func (qb *QueryBuilder) GroupBy(field string) *QueryBuilder

GroupBy adds grouping

func (*QueryBuilder) Not

func (qb *QueryBuilder) Not(field string, op Operator, value interface{}) *QueryBuilder

Not is a shortcut for Add with NQ logical (negates the next clause)

func (*QueryBuilder) Or

func (qb *QueryBuilder) Or(field string, op Operator, value interface{}) *QueryBuilder

Or is a shortcut for Add with Or logical

func (*QueryBuilder) OrderBy

func (qb *QueryBuilder) OrderBy(field string) *QueryBuilder

OrderBy adds sorting (asc)

func (*QueryBuilder) OrderByDesc

func (qb *QueryBuilder) OrderByDesc(field string) *QueryBuilder

OrderByDesc adds sorting (desc)

type TableClient

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

func NewTableClient

func NewTableClient(client *core.Client, name string) *TableClient

func (*TableClient) Contains

func (t *TableClient) Contains(field string, value interface{}) *TableQuery

Contains creates a query builder with a contains condition (convenience method)

func (*TableClient) Create

func (t *TableClient) Create(record map[string]interface{}) (map[string]interface{}, error)

Create inserts a new record using POST

func (*TableClient) CreateWithContext

func (t *TableClient) CreateWithContext(ctx context.Context, record map[string]interface{}) (map[string]interface{}, error)

CreateWithContext inserts a new record using POST with context support

func (*TableClient) Delete

func (t *TableClient) Delete(sysID string) error

Delete removes a record using DELETE

func (*TableClient) DeleteWithContext

func (t *TableClient) DeleteWithContext(ctx context.Context, sysID string) error

DeleteWithContext removes a record using DELETE with context support

func (*TableClient) Equals

func (t *TableClient) Equals(field string, value interface{}) *TableQuery

Equals creates a query builder with an equality condition (convenience method)

func (*TableClient) Get

func (t *TableClient) Get(sysID string) (map[string]interface{}, error)

Get retrieves a single record by sys_id

func (*TableClient) GetKeys

func (t *TableClient) GetKeys(query string) ([]string, error)

GetKeys retrieves sys_ids matching a query

func (*TableClient) GetSchema

func (t *TableClient) GetSchema() ([]core.ColumnMetadata, error)

GetSchema retrieves table metadata via sys_dictionary (JSON)

func (*TableClient) GetWithContext

func (t *TableClient) GetWithContext(ctx context.Context, sysID string) (map[string]interface{}, error)

GetWithContext retrieves a single record by sys_id with context support

func (*TableClient) List

func (t *TableClient) List(params map[string]string) ([]map[string]interface{}, error)

List retrieves records from the table

func (*TableClient) ListOpt

func (t *TableClient) ListOpt(options ListOptions) ([]map[string]interface{}, error)

ListOpt performs List with type-safe options

func (*TableClient) ListWithContext

func (t *TableClient) ListWithContext(ctx context.Context, params map[string]string) ([]map[string]interface{}, error)

ListWithContext retrieves records from the table with context support

func (*TableClient) ListWithQuery

func (t *TableClient) ListWithQuery(qb *query.QueryBuilder) ([]map[string]interface{}, error)

ListWithQuery executes a query using the query builder

func (*TableClient) ListWithQueryContext

func (t *TableClient) ListWithQueryContext(ctx context.Context, qb *query.QueryBuilder) ([]map[string]interface{}, error)

ListWithQueryContext executes a query using the query builder with context support

func (*TableClient) Paginate

func (t *TableClient) Paginate(options ListOptions, pageSize int) ([]map[string]interface{}, error)

Paginate fetches all records by auto-paginating (calls ListOpt repeatedly)

func (*TableClient) Put

func (t *TableClient) Put(sysID string, record map[string]interface{}) (map[string]interface{}, error)

Put performs a full replace using PUT (use sparingly, as PATCH is preferred)

func (*TableClient) Query

func (t *TableClient) Query() *query.QueryBuilder

Query returns a new QueryBuilder for this table

func (*TableClient) Update

func (t *TableClient) Update(sysID string, record map[string]interface{}) (map[string]interface{}, error)

Update performs a partial update using PATCH

func (*TableClient) UpdateWithContext

func (t *TableClient) UpdateWithContext(ctx context.Context, sysID string, record map[string]interface{}) (map[string]interface{}, error)

UpdateWithContext performs a partial update using PATCH with context support

func (*TableClient) Where

func (t *TableClient) Where(field string, operator query.Operator, value interface{}) *TableQuery

Where creates a query builder with an initial condition

type TableQuery

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

TableQuery wraps a query builder with table-specific methods

func (*TableQuery) And

func (tq *TableQuery) And() *TableQuery

And adds an AND condition (chainable)

func (*TableQuery) Contains

func (tq *TableQuery) Contains(field string, value interface{}) *TableQuery

Contains adds a contains condition (chainable)

func (*TableQuery) Count

func (tq *TableQuery) Count() (int, error)

Count returns the number of records matching the query

func (*TableQuery) CountWithContext

func (tq *TableQuery) CountWithContext(ctx context.Context) (int, error)

CountWithContext returns the number of records matching the query with context support

func (*TableQuery) Equals

func (tq *TableQuery) Equals(field string, value interface{}) *TableQuery

Equals adds an equality condition (chainable)

func (*TableQuery) Execute

func (tq *TableQuery) Execute() ([]map[string]interface{}, error)

Execute runs the query and returns results

func (*TableQuery) ExecuteOne

func (tq *TableQuery) ExecuteOne() (map[string]interface{}, error)

ExecuteOne runs the query and returns the first result

func (*TableQuery) ExecuteOneWithContext

func (tq *TableQuery) ExecuteOneWithContext(ctx context.Context) (map[string]interface{}, error)

ExecuteOneWithContext runs the query with context and returns the first result

func (*TableQuery) ExecuteWithContext

func (tq *TableQuery) ExecuteWithContext(ctx context.Context) ([]map[string]interface{}, error)

ExecuteWithContext runs the query with context support and returns results

func (*TableQuery) Fields

func (tq *TableQuery) Fields(fields ...string) *TableQuery

Fields specifies which fields to return (chainable)

func (*TableQuery) GetBuilder

func (tq *TableQuery) GetBuilder() *query.QueryBuilder

GetBuilder returns the underlying query builder

func (*TableQuery) Limit

func (tq *TableQuery) Limit(limit int) *TableQuery

Limit sets the maximum number of records (chainable)

func (*TableQuery) Offset

func (tq *TableQuery) Offset(offset int) *TableQuery

Offset sets the number of records to skip (chainable)

func (*TableQuery) Or

func (tq *TableQuery) Or() *TableQuery

Or adds an OR condition (chainable)

func (*TableQuery) OrderBy

func (tq *TableQuery) OrderBy(field string, direction query.OrderDirection) *TableQuery

OrderBy adds ordering (chainable)

func (*TableQuery) OrderByAsc

func (tq *TableQuery) OrderByAsc(field string) *TableQuery

OrderByAsc adds ascending order (chainable)

func (*TableQuery) OrderByDesc

func (tq *TableQuery) OrderByDesc(field string) *TableQuery

OrderByDesc adds descending order (chainable)

func (*TableQuery) Where

func (tq *TableQuery) Where(field string, operator query.Operator, value interface{}) *TableQuery

Where adds another condition (chainable)

Jump to

Keyboard shortcuts

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