script

package
v0.4.8 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2016 License: Apache-2.0 Imports: 10 Imported by: 0

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

Documentation

Index

Constants

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

Contains the name of Mongo collections.

Variables

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

Set of error variables.

Functions

func Delete

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

Delete is used to remove an existing Set document.

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.

Types

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 GetAll

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

GetAll retrieves a list of scripts.

func GetByName

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

GetByName retrieves the document for the specified name.

func GetByNames

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

GetByNames retrieves the documents for the specified names.

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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