db

package
v0.0.0-...-48b9d42 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultSMSDBName default db name of sms
	DefaultSMSDBName = "sms"

	// SMDocumentCollection the collection name of short message
	SMDocumentCollection = "sm"
)
View Source
const (
	// DefaultSESDBName default db name of ses
	DefaultSESDBName = "ses"

	// EmailDocumentCollection the collection name of email
	EmailDocumentCollection = "email"

	// DefaultLimit default limit
	DefaultLimit = 50
)
View Source
const (
	// EmailRelationDocumentCollection the collection name of email relation
	EmailRelationDocumentCollection = "email_relation"
)

Variables

This section is empty.

Functions

func CountEmailDocumentByWhere

func CountEmailDocumentByWhere(ctx context.Context, db *mongo.Database, where EmailDocumentWhere) (int64, error)

CountEmailDocumentByWhere count email documents by condition from the db

func CountEmailRelationDocumentByWhere

func CountEmailRelationDocumentByWhere(ctx context.Context, db *mongo.Database,
	where EmailRelationDocumentWhere) (int64, error)

CountEmailRelationDocumentByWhere gets email relation document by condition from the db

func CountSMDocumentByWhere

func CountSMDocumentByWhere(ctx context.Context, db *mongo.Database, where SMDocumentWhere) (int64, error)

CountSMDocumentByWhere count short message documents by condition from the db

func EmailDocumentCreateIndexes

func EmailDocumentCreateIndexes(ctx context.Context, db *mongo.Database) error

EmailDocumentCreateIndexes create indexes to optimize the query.

func EmailRelationDocumentCreateIndexes

func EmailRelationDocumentCreateIndexes(ctx context.Context, db *mongo.Database) error

EmailRelationDocumentCreateIndexes create indexes to optimize the query.

func IsErrDuplicateKey

func IsErrDuplicateKey(err error) bool

IsErrDuplicateKey return true

func IsErrNoDocuments

func IsErrNoDocuments(err error) bool

IsErrNoDocuments return true

func SMDocumentCreateIndexes

func SMDocumentCreateIndexes(ctx context.Context, db *mongo.Database) error

SMDocumentCreateIndexes create indexes to optimize the query.

Types

type EmailAttachment

type EmailAttachment struct {
	Name string `bson:"name,omitempty"`
	URL  string `bson:"url,omitempty"`
}

EmailAttachment attachment in mail

type EmailContentSubDocument

type EmailContentSubDocument struct {
	From        string            `bson:"from,omitempty"`
	To          []string          `bson:"to,omitempty"`
	Cc          []string          `bson:"cc,omitempty"`
	Bcc         []string          `bson:"bcc,omitempty"`
	Subject     string            `bson:"subject,omitempty"`
	HTML        string            `bson:"html,omitempty"`
	Text        string            `bson:"text,omitempty"`
	Attachments []EmailAttachment `bson:"attachments,omitempty"`
}

EmailContentSubDocument storing sub documents for email

type EmailDocument

type EmailDocument struct {
	ID       primitive.ObjectID      `bson:"_id,omitempty"`
	EID      string                  `bson:"eid,omitempty"`
	ReID     string                  `bson:"reid,omitempty"`
	SendDate time.Time               `bson:"sendDate,omitempty"`
	Status   string                  `bson:"status,omitempty"`
	Reason   string                  `bson:"reason,omitempty"`
	Content  EmailContentSubDocument `bson:"content,omitempty"`
}

EmailDocument storing documents for email

func EmailDocumentByEID

func EmailDocumentByEID(ctx context.Context, db *mongo.Database, eid string) (*EmailDocument, error)

EmailDocumentByEID gets a email document by eid from the db

func EmailDocumentByIDs

func EmailDocumentByIDs(ctx context.Context, db *mongo.Database, ids []primitive.ObjectID) ([]*EmailDocument, error)

EmailDocumentByIDs gets list of email document by ids from the db

func EmailDocumentByWhere

func EmailDocumentByWhere(ctx context.Context, db *mongo.Database, where EmailDocumentWhere) ([]*EmailDocument, error)

EmailDocumentByWhere gets pagination list of email document by condition from the db

func (*EmailDocument) Collection

func (doc *EmailDocument) Collection() string

Collection return collection name

func (*EmailDocument) Insert

func (doc *EmailDocument) Insert(ctx context.Context, db *mongo.Database) error

Insert insert a email to db

type EmailDocumentWhere

type EmailDocumentWhere struct {
	StartTime time.Time
	EndTime   time.Time
	From      string
	To        string
	Cc        string
	Bcc       string

	// pagination info
	Limit  int64
	Offset int64
	LastID *primitive.ObjectID
}

EmailDocumentWhere query condition

type EmailRelationDocument

type EmailRelationDocument struct {
	ID   primitive.ObjectID `bson:"_id,omitempty"`
	OID  primitive.ObjectID `bson:"oid,omitempty"`
	EID  string             `bson:"eid,omitempty"`
	From string             `bson:"from,omitempty"`
	To   string             `bson:"to,omitempty"`
	Tp   string             `bson:"tp,omitempty"`
}

EmailRelationDocument storing to addr relation document for email

func EmailRelationDocumentByWhere

func EmailRelationDocumentByWhere(ctx context.Context, db *mongo.Database,
	where EmailRelationDocumentWhere) ([]*EmailRelationDocument, error)

EmailRelationDocumentByWhere gets email relation document by condition from the db

func (*EmailRelationDocument) Collection

func (doc *EmailRelationDocument) Collection() string

Collection return collection name

func (*EmailRelationDocument) Insert

func (doc *EmailRelationDocument) Insert(ctx context.Context, db *mongo.Database) error

Insert insert a email relation to db

type EmailRelationDocumentWhere

type EmailRelationDocumentWhere struct {
	From string
	To   string
	Tp   string

	// pagination info
	Limit  int64
	LastID *primitive.ObjectID
}

EmailRelationDocumentWhere query condition

type SMDocument

type SMDocument struct {
	ID       primitive.ObjectID `bson:"_id,omitempty"`
	MID      string             `bson:"mid,omitempty"`
	OmID     string             `bson:"omid,omitempty"`
	SendDate time.Time          `bson:"sendDate,omitempty"`
	Status   string             `bson:"status,omitempty"`
	Reason   string             `bson:"reason,omitempty"`
	Mobile   string             `bson:"mobile,omitempty"`
	Message  string             `bson:"message,omitempty"`
}

SMDocument storing documents for short message

func SMDocumentByMID

func SMDocumentByMID(ctx context.Context, db *mongo.Database, mid string) (*SMDocument, error)

SMDocumentByMID gets a short message document by mid from the db

func SMDocumentByWhere

func SMDocumentByWhere(ctx context.Context, db *mongo.Database, where SMDocumentWhere) ([]*SMDocument, error)

SMDocumentByWhere gets pagination list of short message document by condition from the db

func (*SMDocument) Collection

func (doc *SMDocument) Collection() string

Collection return collection name

func (*SMDocument) Insert

func (doc *SMDocument) Insert(ctx context.Context, db *mongo.Database) error

Insert insert a short message to db

type SMDocumentWhere

type SMDocumentWhere struct {
	StartTime time.Time
	EndTime   time.Time
	Mobile    string

	// pagination info
	Limit  int64
	Offset int64
	LastID *primitive.ObjectID
}

SMDocumentWhere query condition

Jump to

Keyboard shortcuts

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