db

package
v0.0.0-...-c528213 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	DELETE_OPERATION = 1
	INSERT_OPERATION = 2
	UPDATE_OPERATION = 3

	SentCollection       = "sent_notifications"
	StatsCollection      = "last_seen_at"
	TopicCollection      = "topics"
	UserLocaleCollection = "user_locales"
	DeviceCollection     = "devices"

	SavedEmailCollection     = "saved_email"
	SavedPushCollection      = "saved_push"
	SavedWebCollection       = "saved_web"
	AvailableTopicCollection = "topics_available"

	ProcessedCollection = "processed"
)
View Source
const BLANK = ""

Variables

This section is empty.

Functions

func AlterDoc

func AlterDoc(doc *utils.M, operator string, operation utils.M)

func CleanupCollections

func CleanupCollections()

func GetIndexes

func GetIndexes() map[string]index

func InArray

func InArray(key string, arrays ...[]string) bool

Types

type Attachment

type Attachment struct {
	Url          string `json:"url" bson:"url"`
	ThumbnailUrl string `json:"thumbnail_url" bson:"thumbnail_url"`
	Name         string `json:"name" bson:"name"`
	Type         string `json:"type" bson:"type"`
	IsPrivate    bool   `json:"is_private" bson:"is_private"`
}

type AvailableTopic

type AvailableTopic struct {
	BaseModel `bson:",inline"`
	Ident     string   `json:"ident" bson:"ident" required:"true" form:"ident" binding:"required"`
	AppName   string   `json:"app_name" bson:"app_name" required:"true" form:"app_name" binding:"required"`
	Channels  []string `json:"channels" bson:"channels" required:"true" form:"channels" binding:"required"`
}

type BaseInterface

type BaseInterface interface {
	PrepareSave()
}

type BaseModel

type BaseModel struct {
	Id         bson.ObjectId `json:"_id,omitempty" bson:"_id" required:"true"`
	CreatedOn  int64         `json:"created_on" bson:"created_on" required:"true"`
	ModifiedOn int64         `json:"updated_on" bson:"updated_on" required:"true"`
}

func (*BaseModel) PrepareSave

func (self *BaseModel) PrepareSave()

type Channel

type Channel struct {
	Name    string `json:"name" bson:"name"`
	Enabled bool   `json:"enabled" bson:"enabled"`
	Default bool   `json:"default" bson:"default"`
	Locked  bool   `json:"locked" bson:"locked"`
}

type Device

type Device struct {
	BaseModel   `bson:",inline"`
	Token       string `json:"token" bson:"token" required:"true"`
	Type        string `json:"type" bson:"type" required:"true"`
	EndpointArn string `json:"endpoint_arn" bson:"endpoint_arn" required:"true"`
}

type DeviceToken

type DeviceToken struct {
	Type         string `json:"type" bson:"type"`
	Token        string `json:"token" bson:"token"`
	AppName      string `json:"app_name" bson:"app_name"`
	AppVariant   string `bson:"app_variant" json:"app_variant"`
	AppVersion   string `bson:"app_version" json:"app_version"`
	AppUniversal bool   `bson:"app_universal" json:"app_universal"`
}

type LastSeen

type LastSeen struct {
	BaseModel    `bson:",inline"`
	User         string `json:"user" bson:"user" required:"true"`
	Organization string `json:"org" bson:"org"`
	AppName      string `json:"app_name" bson:"app_name"`
	Timestamp    int64  `json:"timestamp" bson:"timestamp" required:"true"`
}

type MConn

type MConn struct {
	Session    *mgo.Session
	Dbname     string
	ConnString string
}
var Conn *MConn

func GetConn

func GetConn(connString, db_name string) *MConn

func (*MConn) Count

func (self *MConn) Count(table string, query utils.M) int

func (*MConn) Delete

func (self *MConn) Delete(table string, query utils.M) error

func (*MConn) FindAndUpdate

func (self *MConn) FindAndUpdate(
	table string, query utils.M, doc utils.M, result interface{},
) (*mgo.ChangeInfo, error)

func (*MConn) Get

func (self *MConn) Get(session *mgo.Session, table string,
	query utils.M) *mgo.Iter

func (*MConn) GetCursor

func (self *MConn) GetCursor(session *mgo.Session, table string,
	query utils.M) *mgo.Query

func (*MConn) GetOne

func (self *MConn) GetOne(table string, query utils.M,
	result interface{}) error

func (*MConn) InitIndexes

func (self *MConn) InitIndexes()

func (*MConn) Insert

func (self *MConn) Insert(table string, arguments ...interface{}) (_id string)

func (*MConn) InsertMulti

func (self *MConn) InsertMulti(table string, arguments ...interface{}) (error, *mgo.BulkResult)

func (*MConn) Update

func (self *MConn) Update(table string, query utils.M, doc utils.M) error

func (*MConn) Upsert

func (self *MConn) Upsert(table string, query utils.M, doc utils.M) error

type PendingItem

type PendingItem struct {
	BaseModel      `bson:",inline"`
	CreatedBy      string                 `json:"created_by" bson:"created_by" required:"true"`
	Organization   string                 `json:"org" bson:"org" required:"true"`
	AppName        string                 `json:"app_name" bson:"app_name" required:"true"`
	Topic          string                 `json:"topic" bson:"topic" required:"true"`
	IsPending      bool                   `json:"is_pending" bson:"is_pending" required:"true"`
	User           string                 `json:"user" bson:"user" required:"true"`
	DestinationUri string                 `json:"destination_uri" bson:"destination_uri"`
	Context        map[string]interface{} `json:"context" bson:"context" required:"true"`
	IsRead         bool                   `json:"is_read" bson:"is_read"`
	Entity         string                 `json:"entity" bson:"entity" required:"true"`
	DeviceTokens   []DeviceToken          `json:"device_tokens" bson:"device_tokens"`
	Download       Attachment             `json:"download" bson:"download"`
	Attachments    []Attachment           `json:"attachments" bson:"attachments"`
}

func (*PendingItem) IsValid

func (self *PendingItem) IsValid() bool

type Processed

type Processed struct {
	BaseModel    `bson:",inline"`
	User         string `bson:"user"`
	Organization string `bson:"org"`
}

type SavedItem

type SavedItem struct {
	BaseModel `bson:",inline"`
	Data      interface{} `bson:"data"`
	Details   PendingItem `bson:"details"`
}

type SentItem

type SentItem struct {
	BaseModel      `bson:",inline"`
	CreatedBy      string                 `json:"created_by" bson:"created_by" required:"true"`
	Organization   string                 `json:"org" bson:"org" required:"true"`
	AppName        string                 `json:"app_name" bson:"app_name" required:"true"`
	Topic          string                 `json:"topic" bson:"topic" required:"true"`
	User           string                 `json:"user" bson:"user" required:"true"`
	DestinationUri string                 `json:"destination_uri" bson:"destination_uri"`
	Text           string                 `json:"text" bson:"text" required:"true"`
	IsRead         bool                   `json:"is_read" bson:"is_read"`
	Context        map[string]interface{} `json:"context" bson:"context"`
	Entity         string                 `json:"entity" bson:"entity" required:"true"`
}

type Topic

type Topic struct {
	BaseModel    `bson:",inline"`
	User         string    `json:"user" bson:"user"`
	Organization string    `json:"org" bson:"org"`
	Channels     []Channel `json:"channels" bson:"channels" required:"true"`
	Ident        string    `json:"ident" bson:"ident" required:"true" form:"ident" binding:"required"`
}

Jump to

Keyboard shortcuts

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