Documentation
¶
Index ¶
- Constants
- Variables
- func CreateType(name string, entry *Entry) (*starlark_type.StarlarkType, error)
- func NewStorePlugin(pluginContext *types.PluginContext) (any, error)
- type Document
- type Entry
- type EntryId
- type SqlStore
- func (s *SqlStore) Begin(ctx context.Context) (*sql.Tx, error)
- func (s *SqlStore) Commit(ctx context.Context, tx *sql.Tx) error
- func (s *SqlStore) Count(ctx context.Context, tx *sql.Tx, table string, filter map[string]any) (int64, error)
- func (s *SqlStore) Delete(ctx context.Context, tx *sql.Tx, table string, filter map[string]any) (int64, error)
- func (s *SqlStore) DeleteById(ctx context.Context, tx *sql.Tx, table string, id EntryId) (int64, error)
- func (s *SqlStore) Insert(ctx context.Context, tx *sql.Tx, table string, entry *Entry) (EntryId, error)
- func (s *SqlStore) Rollback(ctx context.Context, tx *sql.Tx) error
- func (s *SqlStore) Select(ctx context.Context, tx *sql.Tx, thread *starlark.Thread, table string, ...) (starlark.Iterable, error)
- func (s *SqlStore) SelectById(ctx context.Context, tx *sql.Tx, table string, id EntryId) (*Entry, error)
- func (s *SqlStore) SelectOne(ctx context.Context, tx *sql.Tx, table string, filter map[string]any) (*Entry, error)
- func (s *SqlStore) Update(ctx context.Context, tx *sql.Tx, table string, entry *Entry) (int64, error)
- type Store
- type StoreEntryIterable
- type StoreEntryIterator
- type UserId
Constants ¶
View Source
const ( AND_CONDITION = "$AND" OR_CONDITION = "$OR" )
View Source
const ( SELECT_MAX_LIMIT = 100_000 SELECT_DEFAULT_LIMIT = 10_000 SORT_ASCENDING = "asc" SORT_DESCENDING = "desc" )
View Source
const ( ID_FIELD = "_id" VERSION_FIELD = "_version" CREATED_BY_FIELD = "_created_by" UPDATED_BY_FIELD = "_updated_by" CREATED_AT_FIELD = "_created_at" UPDATED_AT_FIELD = "_updated_at" JSON_FIELD = "_json" )
View Source
const (
TRANSACTION_KEY = "transaction"
)
Variables ¶
View Source
var RESERVED_FIELDS = map[string]bool{ ID_FIELD: true, VERSION_FIELD: true, CREATED_BY_FIELD: true, UPDATED_BY_FIELD: true, CREATED_AT_FIELD: true, UPDATED_AT_FIELD: true, JSON_FIELD: true, }
Functions ¶
func CreateType ¶
func CreateType(name string, entry *Entry) (*starlark_type.StarlarkType, error)
func NewStorePlugin ¶
func NewStorePlugin(pluginContext *types.PluginContext) (any, error)
Types ¶
type Entry ¶
type SqlStore ¶
func NewSqlStore ¶
func NewSqlStore(pluginContext *types.PluginContext) (*SqlStore, error)
func (*SqlStore) Count ¶
func (s *SqlStore) Count(ctx context.Context, tx *sql.Tx, table string, filter map[string]any) (int64, error)
Count returns the number of entries matching the filter
func (*SqlStore) Delete ¶
func (s *SqlStore) Delete(ctx context.Context, tx *sql.Tx, table string, filter map[string]any) (int64, error)
Delete entries from the store matching the filter
func (*SqlStore) DeleteById ¶
func (s *SqlStore) DeleteById(ctx context.Context, tx *sql.Tx, table string, id EntryId) (int64, error)
DeleteById an entry from the store by id
func (*SqlStore) Insert ¶
func (s *SqlStore) Insert(ctx context.Context, tx *sql.Tx, table string, entry *Entry) (EntryId, error)
Insert a new entry in the store
func (*SqlStore) Select ¶
func (s *SqlStore) Select(ctx context.Context, tx *sql.Tx, thread *starlark.Thread, table string, filter map[string]any, sort []string, offset, limit int64) (starlark.Iterable, error)
Select returns the entries matching the filter
func (*SqlStore) SelectById ¶
func (s *SqlStore) SelectById(ctx context.Context, tx *sql.Tx, table string, id EntryId) (*Entry, error)
SelectById returns a single item from the store
type Store ¶
type Store interface { // Begin starts a new transaction Begin(ctx context.Context) (*sql.Tx, error) // Commit commits a transaction Commit(ctx context.Context, tx *sql.Tx) error // Rollback rolls back a transaction Rollback(ctx context.Context, tx *sql.Tx) error // Insert a new entry in the store Insert(ctx context.Context, tx *sql.Tx, table string, Entry *Entry) (EntryId, error) // SelectById returns a single item from the store SelectById(ctx context.Context, tx *sql.Tx, table string, id EntryId) (*Entry, error) // SelectOne returns a single item from the store SelectOne(ctx context.Context, tx *sql.Tx, table string, filter map[string]any) (*Entry, error) // Select returns the entries matching the filter Select(ctx context.Context, tx *sql.Tx, thread *starlark.Thread, table string, filter map[string]any, sort []string, offset, limit int64) (starlark.Iterable, error) // Count returns the count of entries matching the filter Count(ctx context.Context, tx *sql.Tx, table string, filter map[string]any) (int64, error) // Update an existing entry in the store Update(ctx context.Context, tx *sql.Tx, table string, Entry *Entry) (int64, error) // DeleteById an entry from the store by id DeleteById(ctx context.Context, tx *sql.Tx, table string, id EntryId) (int64, error) // Delete entries from the store matching the filter Delete(ctx context.Context, tx *sql.Tx, table string, filter map[string]any) (int64, error) }
Store is the interface for a Clace document store. These API are exposed by the db plugin
type StoreEntryIterable ¶
func NewStoreEntryIterabe ¶
func (*StoreEntryIterable) Freeze ¶
func (s *StoreEntryIterable) Freeze()
func (*StoreEntryIterable) Hash ¶
func (s *StoreEntryIterable) Hash() (uint32, error)
func (*StoreEntryIterable) Iterate ¶
func (s *StoreEntryIterable) Iterate() starlark.Iterator
func (*StoreEntryIterable) String ¶
func (s *StoreEntryIterable) String() string
func (*StoreEntryIterable) Truth ¶
func (s *StoreEntryIterable) Truth() starlark.Bool
func (*StoreEntryIterable) Type ¶
func (s *StoreEntryIterable) Type() string
type StoreEntryIterator ¶
func NewStoreEntryIterator ¶
func (*StoreEntryIterator) Done ¶
func (i *StoreEntryIterator) Done()
Click to show internal directories.
Click to hide internal directories.