mongo

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2023 License: MIT Imports: 17 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

func New

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"`
	Created time.Time          `bson:"created" json:"created"`
}

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     string             `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 cache.PublishDocumentEvent
	// contains filtered or unexported fields
}

func (*Mongo) ActivateTenant added in v1.4.1

func (mg *Mongo) ActivateTenant(tenantID string, active bool) error

func (*Mongo) AddFile

func (mg *Mongo) AddFile(dbName string, f model.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 model.ExecData) (string, error)

func (*Mongo) AddTask added in v1.5.0

func (mg *Mongo) AddTask(dbName string, task model.Task) (string, error)

func (*Mongo) BulkCreateDocument

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

func (*Mongo) ChangeTenantPlan added in v1.4.1

func (mg *Mongo) ChangeTenantPlan(tenantID string, plan int) error

func (*Mongo) Count added in v1.4.3

func (mg *Mongo) Count(auth model.Auth, dbName, col string, filter map[string]interface{}) (count int64, err error)

func (*Mongo) CreateAccount added in v1.4.1

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

func (*Mongo) CreateDatabase added in v1.4.1

func (mg *Mongo) CreateDatabase(base model.DatabaseConfig) (model.DatabaseConfig, error)

func (*Mongo) CreateDocument

func (mg *Mongo) CreateDocument(auth model.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) CreateTenant added in v1.4.1

func (mg *Mongo) CreateTenant(customer model.Tenant) (model.Tenant, error)

func (*Mongo) CreateUser added in v1.4.1

func (mg *Mongo) CreateUser(dbName string, tok model.User) (id string, err error)

func (*Mongo) DatabaseExists

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

func (*Mongo) DeleteDocument

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

func (*Mongo) DeleteDocuments added in v1.5.0

func (mg *Mongo) DeleteDocuments(auth model.Auth, dbName, col string, filters map[string]any) (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) DeleteTask added in v1.5.0

func (mg *Mongo) DeleteTask(dbName, id string) error

func (*Mongo) DeleteTenant added in v1.4.1

func (mg *Mongo) DeleteTenant(dbName, email 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(tenantID string, config map[string]model.OAuthConfig) error

func (*Mongo) FindDatabase

func (mg *Mongo) FindDatabase(baseID string) (conf model.DatabaseConfig, err error)

func (*Mongo) FindRootUser added in v1.4.1

func (mg *Mongo) FindRootUser(dbName, userID, accountID, token string) (tok model.User, err error)

func (*Mongo) FindTenant added in v1.4.1

func (mg *Mongo) FindTenant(tenantID string) (cus model.Tenant, err error)

func (*Mongo) FindUser added in v1.4.1

func (mg *Mongo) FindUser(dbName, userID, token string) (tok model.User, err error)

func (*Mongo) FindUserByEmail added in v1.4.1

func (mg *Mongo) FindUserByEmail(dbName, email string) (tok model.User, err error)

func (*Mongo) GetDocumentByID

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

func (*Mongo) GetDocumentsByIDs added in v1.4.2

func (mg *Mongo) GetDocumentsByIDs(auth model.Auth, dbName, col string, ids []string) (docs []map[string]interface{}, err error)

func (*Mongo) GetFileByID

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

func (*Mongo) GetFirstUserFromAccountID added in v1.4.1

func (mg *Mongo) GetFirstUserFromAccountID(dbName, accountID string) (tok model.User, err error)

func (*Mongo) GetForms

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

func (*Mongo) GetFunctionByID

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

func (*Mongo) GetFunctionByName

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

func (*Mongo) GetFunctionForExecution

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

func (*Mongo) GetRootForBase

func (mg *Mongo) GetRootForBase(dbName string) (tok model.User, err error)

func (*Mongo) GetTenantByStripeID added in v1.4.1

func (mg *Mongo) GetTenantByStripeID(stripeID string) (cus model.Tenant, err error)

func (*Mongo) GetUserByID added in v1.5.0

func (mg *Mongo) GetUserByID(dbName, accountID, userID string) (user model.User, err error)

func (*Mongo) IncrementMonthlyEmailSent

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

func (*Mongo) IncrementValue

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

func (*Mongo) ListAccounts added in v1.5.0

func (mg *Mongo) ListAccounts(dbName string) ([]model.Account, error)

func (*Mongo) ListAllFiles added in v1.4.0

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

func (*Mongo) ListCollections

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

func (*Mongo) ListDatabases

func (mg *Mongo) ListDatabases() (results []model.DatabaseConfig, err error)

func (*Mongo) ListDocuments

func (mg *Mongo) ListDocuments(auth model.Auth, dbName, col string, params model.ListParams) (model.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 []model.ExecData, err error)

func (*Mongo) ListFunctionsByTrigger

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

func (*Mongo) ListTasks

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

func (*Mongo) ListTasksByBase added in v1.5.0

func (mg *Mongo) ListTasksByBase(dbName string) ([]model.Task, error)

func (*Mongo) ListUsers added in v1.5.0

func (mg *Mongo) ListUsers(dbName, accountID string) ([]model.User, 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 model.Auth, dbName, col string, filter map[string]interface{}, params model.ListParams) (model.PagedResult, error)

func (*Mongo) RanFunction

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

func (*Mongo) RemoveUser added in v1.5.0

func (mg *Mongo) RemoveUser(auth model.Auth, dbName, userID string) 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 model.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 model.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