mongo

package
v1.4.0-beta1 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FieldID        = "_id"
	FieldAccountID = "accountId"
	FieldOwnerID   = "sb_owner"
	FieldToken     = "token"
	FieldIsActive  = "active"
	FieldRole      = "role"
	FieldFormName  = "form"
)

Variables

This section is empty.

Functions

Types

type Base

type Base struct {
	PublishDocument func(topic, msg string, doc interface{})
}

type LocalAccount

type LocalAccount struct {
	ID    primitive.ObjectID `bson:"_id" json:"id"`
	Email string             `bson:"email" json:"email"`
}

type LocalBase

type LocalBase struct {
	ID               primitive.ObjectID `bson:"_id" json:"id"`
	SBID             primitive.ObjectID `bson:"accountId" json:"-"`
	Name             string             `bson:"name" json:"name"`
	Whitelist        []string           `bson:"whitelist" json:"whitelist"`
	IsActive         bool               `bson:"active" json:"-"`
	MonthlyEmailSent int                `bson:"mes" json:"-"`
}

type LocalCustomer

type LocalCustomer struct {
	ID             primitive.ObjectID `bson:"_id" json:"id"`
	Email          string             `bson:"email" json:"email"`
	StripeID       string             `bson:"stripeId" json:"stripeId"`
	SubscriptionID string             `bson:"subId" json:"subId"`
	Plan           int                `bson:"plan" json:"plan"`
	ExternalLogins []byte             `bson:"et" json:"-"`
	IsActive       bool               `bson:"active" json:"-"`
	Created        time.Time          `bson:"created" json:"created"`
}

type LocalExecData

type LocalExecData struct {
	ID           primitive.ObjectID `bson:"_id" json:"id"`
	FunctionName string             `bson:"name" json:"name"`
	TriggerTopic string             `bson:"tr" json:"trigger"`
	Code         string             `bson:"code" json:"code"`
	Version      int                `bson:"v" json:"version"`
	LastUpdated  time.Time          `bson:"lu" json:"lastUpdated"`
	LastRun      time.Time          `bson:"lr" json:"lastRun"`
	History      []LocalExecHistory `bson:"h" json:"history"`
}

type LocalExecHistory

type LocalExecHistory struct {
	ID        string    `bson:"id" json:"id"`
	Version   int       `bson:"v" json:"version"`
	Started   time.Time `bson:"s" json:"started"`
	Completed time.Time `bson:"c" json:"completed"`
	Success   bool      `bson:"ok" json:"success"`
	Output    []string  `bson:"out" json:"output"`
}

type LocalFile

type LocalFile struct {
	ID        primitive.ObjectID `bson:"_id" json:"id"`
	AccountID primitive.ObjectID `bson:"accountId" json:"accountId"`
	Key       string             `bson:"key" json:"key"`
	URL       string             `bson:"url" json:"url"`
	Size      int64              `bson:"size" json:"size"`
	Uploaded  time.Time          `bson:"on" json:"uploaded"`
}

type LocalMetaMessage

type LocalMetaMessage struct {
	Data    string `bson:"data" json:"data"`
	Channel string `bson:"channel" json:"channel"`
}

type LocalTask

type LocalTask struct {
	ID       primitive.ObjectID `bson:"_id" json:"id"`
	Name     string             `bson:"name" json:"name"`
	Type     string             `bson:"type" json:"type"`
	Value    string             `bson:"value" json:"value"`
	Meta     interface{}        `bson:"meta" json:"meta"`
	Interval string             `bson:"invertal" json:"interval"`
	LastRun  time.Time          `bson:"last" json:"last"`

	BaseName string `bson:"-" json:"base"`
}

type LocalToken

type LocalToken struct {
	ID        primitive.ObjectID `bson:"_id" json:"id"`
	AccountID primitive.ObjectID `bson:"accountId" json:"accountId"`
	Token     string             `bson:"token" json:"token"`
	Email     string             `bson:"email" json:"email"`
	Password  string             `bson:"pw" json:"-"`
	Role      int                `bson:"role" json:"role"`
	ResetCode string             `bson:"resetCode" json:"-"`
	Created   time.Time          `bson:"created" json:"created"`
}

type Mongo

type Mongo struct {
	Client          *mongo.Client
	Ctx             context.Context
	PublishDocument internal.PublishDocumentEvent
	// contains filtered or unexported fields
}

func (*Mongo) ActivateCustomer

func (mg *Mongo) ActivateCustomer(customerID string, active bool) error

func (*Mongo) AddFile

func (mg *Mongo) AddFile(dbName string, f internal.File) (id string, err error)

func (*Mongo) AddFormSubmission

func (mg *Mongo) AddFormSubmission(dbName, form string, doc map[string]interface{}) error

func (*Mongo) AddFunction

func (mg *Mongo) AddFunction(dbName string, data internal.ExecData) (string, error)

func (*Mongo) BulkCreateDocument

func (mg *Mongo) BulkCreateDocument(auth internal.Auth, dbName, col string, docs []interface{}) error

func (*Mongo) ChangeCustomerPlan added in v1.4.0

func (mg *Mongo) ChangeCustomerPlan(customerID string, plan int) error

func (*Mongo) CreateBase

func (mg *Mongo) CreateBase(base internal.BaseConfig) (internal.BaseConfig, error)

func (*Mongo) CreateCustomer

func (mg *Mongo) CreateCustomer(customer internal.Customer) (internal.Customer, error)

func (*Mongo) CreateDocument

func (mg *Mongo) CreateDocument(auth internal.Auth, dbName, col string, doc map[string]interface{}) (map[string]interface{}, error)

func (*Mongo) CreateIndex added in v1.3.0

func (mg *Mongo) CreateIndex(dbName, col, field string) error

func (*Mongo) CreateUserAccount

func (mg *Mongo) CreateUserAccount(dbName, email string) (id string, err error)

func (*Mongo) CreateUserToken

func (mg *Mongo) CreateUserToken(dbName string, tok internal.Token) (id string, err error)

func (*Mongo) DatabaseExists

func (mg *Mongo) DatabaseExists(name string) (bool, error)

func (*Mongo) DeleteCustomer

func (mg *Mongo) DeleteCustomer(dbName, email string) error

func (*Mongo) DeleteDocument

func (mg *Mongo) DeleteDocument(auth internal.Auth, dbName, col, id string) (int64, error)

func (*Mongo) DeleteFile

func (mg *Mongo) DeleteFile(dbName, fileID string) error

func (*Mongo) DeleteFunction

func (mg *Mongo) DeleteFunction(dbName, name string) error

func (*Mongo) EmailExists

func (mg *Mongo) EmailExists(email string) (bool, error)

func (*Mongo) EnableExternalLogin added in v1.4.0

func (mg *Mongo) EnableExternalLogin(customerID string, config map[string]internal.OAuthConfig) error

func (*Mongo) FindAccount

func (mg *Mongo) FindAccount(customerID string) (cus internal.Customer, err error)

func (*Mongo) FindDatabase

func (mg *Mongo) FindDatabase(baseID string) (conf internal.BaseConfig, err error)

func (*Mongo) FindRootToken

func (mg *Mongo) FindRootToken(dbName, tokenID, accountID, token string) (tok internal.Token, err error)

func (*Mongo) FindToken

func (mg *Mongo) FindToken(dbName, tokenID, token string) (tok internal.Token, err error)

func (*Mongo) FindTokenByEmail

func (mg *Mongo) FindTokenByEmail(dbName, email string) (tok internal.Token, err error)

func (*Mongo) GetCustomerByStripeID

func (mg *Mongo) GetCustomerByStripeID(stripeID string) (cus internal.Customer, err error)

func (*Mongo) GetDocumentByID

func (mg *Mongo) GetDocumentByID(auth internal.Auth, dbName, col, id string) (map[string]interface{}, error)

func (*Mongo) GetFileByID

func (mg *Mongo) GetFileByID(dbName, fileID string) (f internal.File, err error)

func (*Mongo) GetFirstTokenFromAccountID

func (mg *Mongo) GetFirstTokenFromAccountID(dbName, accountID string) (tok internal.Token, err error)

func (*Mongo) GetForms

func (mg *Mongo) GetForms(dbName string) ([]string, error)

func (*Mongo) GetFunctionByID

func (mg *Mongo) GetFunctionByID(dbName, id string) (result internal.ExecData, err error)

func (*Mongo) GetFunctionByName

func (mg *Mongo) GetFunctionByName(dbName, name string) (result internal.ExecData, err error)

func (*Mongo) GetFunctionForExecution

func (mg *Mongo) GetFunctionForExecution(dbName, name string) (result internal.ExecData, err error)

func (*Mongo) GetRootForBase

func (mg *Mongo) GetRootForBase(dbName string) (tok internal.Token, err error)

func (*Mongo) IncrementMonthlyEmailSent

func (mg *Mongo) IncrementMonthlyEmailSent(baseID string) error

func (*Mongo) IncrementValue

func (mg *Mongo) IncrementValue(auth internal.Auth, dbName, col, id, field string, n int) error

func (*Mongo) ListAllFiles added in v1.4.0

func (mg *Mongo) ListAllFiles(dbName, accountID string) ([]internal.File, error)

func (*Mongo) ListCollections

func (mg *Mongo) ListCollections(dbName string) ([]string, error)

func (*Mongo) ListDatabases

func (mg *Mongo) ListDatabases() (results []internal.BaseConfig, err error)

func (*Mongo) ListDocuments

func (mg *Mongo) ListDocuments(auth internal.Auth, dbName, col string, params internal.ListParams) (internal.PagedResult, error)

func (*Mongo) ListFormSubmissions

func (mg *Mongo) ListFormSubmissions(dbName, name string) (results []map[string]interface{}, err error)

func (*Mongo) ListFunctions

func (mg *Mongo) ListFunctions(dbName string) (results []internal.ExecData, err error)

func (*Mongo) ListFunctionsByTrigger

func (mg *Mongo) ListFunctionsByTrigger(dbName, trigger string) (results []internal.ExecData, err error)

func (*Mongo) ListTasks

func (mg *Mongo) ListTasks() ([]internal.Task, error)

func (*Mongo) NewID

func (mg *Mongo) NewID() string

func (*Mongo) ParseQuery

func (mg *Mongo) ParseQuery(clauses [][]interface{}) (map[string]interface{}, error)

func (*Mongo) Ping

func (mg *Mongo) Ping() error

func (*Mongo) QueryDocuments

func (mg *Mongo) QueryDocuments(auth internal.Auth, dbName, col string, filter map[string]interface{}, params internal.ListParams) (internal.PagedResult, error)

func (*Mongo) RanFunction

func (mg *Mongo) RanFunction(dbName, id string, rh internal.ExecHistory) error

func (*Mongo) ResetPassword

func (mg *Mongo) ResetPassword(dbName, email, code, password string) error

func (*Mongo) SetPasswordResetCode

func (mg *Mongo) SetPasswordResetCode(dbName, tokenID, code string) error

func (*Mongo) SetUserRole

func (mg *Mongo) SetUserRole(dbName, email string, role int) error

func (*Mongo) UpdateDocument

func (mg *Mongo) UpdateDocument(auth internal.Auth, dbName, col, id string, doc map[string]interface{}) (map[string]interface{}, error)

func (*Mongo) UpdateDocuments added in v1.4.0

func (mg *Mongo) UpdateDocuments(auth internal.Auth, dbName, col string, filters map[string]interface{}, updateFields map[string]interface{}) (n int64, err error)

func (*Mongo) UpdateFunction

func (mg *Mongo) UpdateFunction(dbName, id, code, trigger string) error

func (*Mongo) UserEmailExists

func (mg *Mongo) UserEmailExists(dbName, email string) (exists bool, err error)

func (*Mongo) UserSetPassword

func (mg *Mongo) UserSetPassword(dbName, tokenID, password string) error

Jump to

Keyboard shortcuts

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