db

package
v0.0.0-...-b4989b1 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2015 License: Apache-2.0 Imports: 7 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"
	GullyCollection      = "gullys"
	UserLocaleCollection = "user_locales"

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

	DefaultsCollection  = "defaults"
	LocksCollection     = "locks"
	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 Convert

func Convert(doc utils.M, out interface{})

func InArray

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

Types

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 Defaults

type Defaults struct {
	BaseModel    `bson:",inline"`
	Organization string   `json:"org" bson:"org"`
	Topic        string   `json:"ident" bson:"ident" required:"true"`
	Channels     []string `json:"channels" bson:"channels" required:"true"`
	Enabled      bool     `json:"enabled" bson:"enabled"`
}

type Gully

type Gully struct {
	BaseModel    `bson:",inline"`
	User         string                 `json:"user" bson:"user"`
	Organization string                 `json:"org" bson:"org"`
	AppName      string                 `json:"app_name" bson:"app_name"`
	Data         map[string]interface{} `json:"data" bson:"data" required:"true"`
	Ident        string                 `json:"ident" bson:"ident" required:"true"`
}

func (*Gully) IsValid

func (self *Gully) IsValid(op_type int) bool

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 Locks

type Locks struct {
	BaseModel    `bson:",inline"`
	Organization string   `json:"org" bson:"org" required:"true"`
	Topic        string   `json:"ident" bson:"ident" required:"true"`
	Channels     []string `json:"channels" bson:"channels" required:"true"`
	Enabled      bool     `json:"enabled" bson:"enabled"`
}

type MConn

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

func GetConn

func GetConn(db_name string, address string, creds ...string) *MConn

func (*MConn) Aggregate

func (self *MConn) Aggregate(session *mgo.Session, table string,
	doc []utils.M) *mgo.Pipe

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) DropIndex

func (self *MConn) DropIndex(table string, key ...string) error

func (*MConn) DropIndices

func (self *MConn) DropIndices(table string) error

func (*MConn) EnsureIndex

func (self *MConn) EnsureIndex(table string, index mgo.Index) error

func (*MConn) FindAndUpdate

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

func (*MConn) FindAndUpsert

func (self *MConn) FindAndUpsert(
	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) HintedCount

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

func (*MConn) HintedGetOne

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

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) MapReduce

func (self *MConn) MapReduce(session *mgo.Session, table string,
	query utils.M, result interface{}, job *MapReduce) (*mgo.MapReduceInfo, error)

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 MapReduce

type MapReduce mgo.MapReduce

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" required:"true"`
	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"`
}

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" required:"true"`
	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"`
}

func (*SentItem) IsValid

func (self *SentItem) IsValid() bool

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"`
}

type UserLocale

type UserLocale struct {
	BaseModel `bson:",inline"`
	User      string `json:"user" bson:"user" required:"true"`
	Locale    string `json:"locale" bson:"locale" required:"true"`
	TimeZone  string `json:"timezone" bson:"timezone" required:"true"`
}

func (*UserLocale) IsValid

func (self *UserLocale) IsValid() bool

Jump to

Keyboard shortcuts

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