csvstore

package module
v0.0.0-...-7e006f2 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2025 License: AGPL-3.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CSVRecord

type CSVRecord map[string]string

CSVRecord represents a row in CSV

type CSVStore

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

CSVStore represents a CSV-based storage system

func NewCSVStore

func NewCSVStore(basePath string) (*CSVStore, error)

NewCSVStore creates a new CSV-based storage system

func (*CSVStore) CheckTableExists

func (cs *CSVStore) CheckTableExists(tableName string) bool

CheckTableExists checks if a table exists

func (*CSVStore) CreateTable

func (cs *CSVStore) CreateTable(tableName string, headers []string) error

CreateTable creates a new CSV table with headers

func (*CSVStore) Delete

func (cs *CSVStore) Delete(tableName string, conditions []QueryCondition) (*QueryResult, error)

Delete removes records matching conditions

func (*CSVStore) GetTablePath

func (cs *CSVStore) GetTablePath(tableName string) string

GetTablePath returns the file path for a table (for external access)

func (*CSVStore) Insert

func (cs *CSVStore) Insert(tableName string, record CSVRecord) (CSVRecord, error)

Insert adds a new record to the table

func (*CSVStore) ListTables

func (cs *CSVStore) ListTables() ([]string, error)

ListTables returns all available tables

func (*CSVStore) Query

func (cs *CSVStore) Query(tableName string, conditions []QueryCondition) (*QueryResult, error)

Query executes a query on the CSV table

func (*CSVStore) QuerySortedRange

func (cs *CSVStore) QuerySortedRange(
	tableName string,
	sortField string,
	sortBy string,
	limit int,
) (*QueryResult, error)

QuerySortedRange retrieves a limited number of records from a table, sorted by a specific field. sortBy can be "asc" for ascending or "desc" for descending order. limit specifies the maximum number of records to return. If limit is larger than available records, all records are returned. If limit is negative, an error is returned.

func (*CSVStore) Select

func (cs *CSVStore) Select(
	tableName string,
	columns []string,
	conditions []QueryCondition,
) (*QueryResult, error)

Select retrieves specific columns from query results

func (*CSVStore) Update

func (cs *CSVStore) Update(
	tableName string,
	updates CSVRecord,
	conditions []QueryCondition,
) (*QueryResult, error)

Update updates records matching conditions

type QueryCondition

type QueryCondition struct {
	Column   string
	Operator string // "=", "!=", ">", "<", ">=", "<=", "contains", "starts_with", "ends_with"
	Value    string
}

QueryCondition represents a filter condition

type QueryResult

type QueryResult struct {
	Records []CSVRecord
	Count   int
}

QueryResult represents query results

Jump to

Keyboard shortcuts

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