package
0.4.8
Repository: https://github.com/coralproject/shelf.git
Documentation: pkg.go.dev

# README

script

import "github.com/coralproject/shelf/internal/xenia/script"

Overview

Index

Package files

model.go prepare.go script.go

Constants

const (
    Collection        = "query_scripts"
    CollectionHistory = "query_scripts_history"
)

Contains the name of Mongo collections.

Variables

var (
    ErrNotFound = errors.New("Script Not found")
)

Set of error variables.

func Delete

func Delete(context interface{}, db *db.DB, name string) error

Delete is used to remove an existing Set document.

func GetAll

func GetAll(context interface{}, db *db.DB, tags []string) ([]Script, error)

GetAll retrieves a list of scripts.

func GetByNames

func GetByNames(context interface{}, db *db.DB, names []string) ([]Script, error)

GetByNames retrieves the documents for the specified names.

func GetNames

func GetNames(context interface{}, db *db.DB) ([]string, error)

GetNames retrieves a list of script names.

func Upsert

func Upsert(context interface{}, db *db.DB, scr Script) error

Upsert is used to create or update an existing Script document.

type Script

type Script struct {
    Name     string                   `bson:"name" json:"name" validate:"required,min=3"` // Unique name per Script document
    Commands []map[string]interface{} `bson:"commands" json:"commands"`                   // Commands to add to a query.
}

Script contain pre and post commands to use per set or per query.

func GetByName

func GetByName(context interface{}, db *db.DB, name string) (Script, error)

GetByName retrieves the document for the specified name.

func GetLastHistoryByName

func GetLastHistoryByName(context interface{}, db *db.DB, name string) (Script, error)

GetLastHistoryByName gets the last written Script within the history.

func (Script) PrepareForInsert

func (scr Script) PrepareForInsert()

PrepareForInsert replaces the $ to _$ when found in the front of field names.

func (Script) PrepareForUse

func (scr Script) PrepareForUse()

PrepareForUse replaces the _$ to $ when found in the front of field names.

func (Script) Validate

func (scr Script) Validate() error

Validate checks the query value for consistency.


Generated by godoc2md

# Packages

No description provided by the author

# Functions

Delete is used to remove an existing Set document.
GetAll retrieves a list of scripts.
GetByName retrieves the document for the specified name.
GetByNames retrieves the documents for the specified names.
GetLastHistoryByName gets the last written Script within the history.
GetNames retrieves a list of script names.
Upsert is used to create or update an existing Script document.

# Constants

Contains the name of Mongo collections.
Contains the name of Mongo collections.

# Variables

Set of error variables.

# Structs

Script contain pre and post commands to use per set or per query.