models

package
v0.0.0-...-b5cb8fc Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2018 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

数据库结构

Index

Constants

This section is empty.

Variables

View Source
var (
	Session    *mgo.Session    // 数据库连接对象
	DbPost     *mgo.Collection // Post表对象
	DbTag      *mgo.Collection // Tag表对象
	DbConf     *mgo.Collection // Config表对象
	DbRedirect *mgo.Collection // Redirect表对象
	Option     Conf            // 博客配置
)

Functions

func Count

func Count(collection *mgo.Collection, query interface{}) int

获取统计数据

func Delete

func Delete(collection *mgo.Collection, query interface{}) error

删除一条数据

func GetAllByQuery

func GetAllByQuery(collection *mgo.Collection, query, val interface{})

通过查询条件获取所有数据

func GetDataByQuery

func GetDataByQuery(collection *mgo.Collection, start, length int, fields string, query interface{}, val interface{})

通过查询获取指定数量与排序的数据

func GetOneById

func GetOneById(collection *mgo.Collection, id bson.ObjectId, val interface{})

通过Id获取一条数据

func GetOneByQuery

func GetOneByQuery(collection *mgo.Collection, query, val interface{})

通过查询条件获取一条数据

func Has

func Has(collection *mgo.Collection, query interface{}) bool

数据是否存在

func Insert

func Insert(collection *mgo.Collection, data interface{}) error

创建一条数据

func SetAdd

func SetAdd(collection *mgo.Collection, query interface{}, field string, add bool) error

数据自增或自减

func SetOption

func SetOption(sitename, subtitle, keywords, description, author, email string)

设置配置信息

func Tag

func Tag(caption, slug string) error

保存标签数据

func Update

func Update(collection *mgo.Collection, query, data interface{}) error

更新一条数据

Types

type Conf

type Conf struct {
	SiteName    string `bson:"sitename"`    // 博客名称
	SubTitle    string `bson:"subtitle"`    // 博客子标题
	Keywords    string `bson:"keywords"`    // 博客关键字
	Description string `bson:"description"` // 博客描述
	Author      string `bson:"author"`      // 博客作者名称
	Email       string `bson:"email"`       // 博客作者邮箱
}

博客配置结构

type DB

type DB struct {
	Host string // MongoDB连接地址
	Port int    // MongoDB连接端口
	Name string // MongoDB数据库名
	User string // MongoDB连接用户名
	Pass string // MongoDB连接密码
}

数据库结构

type Key

type Key struct {
	Caption string // 关键字名称
	Slug    string // 关键字固定连接
	IsTag   bool   // 是否为标签
}

关键字结构

type SC_Config

type SC_Config struct {
	Id     bson.ObjectId `_id`
	SetKey string        `bson:"setkey"` // 配置键
	SetVal string        `bson:"setval"` // 配置值
}

SC_Config表结构

type SC_Post

type SC_Post struct {
	Id       bson.ObjectId `_id`             // 数据编号
	Caption  string        `bson:"caption"`  // 文章标题
	Slug     string        `bson:"slug"`     // 文章固定链接
	Tags     []string      `bson:"tags"`     // 文章标签列表
	Created  int64         `bson:"created"`  // 文章创建时间戳
	Markdown string        `bson:"markdown"` // 文章Markdown内容
	Html     string        `bson:"html"`     // 文章Html内容
	Cover    string        `bson:"cover"`    // 文章封面
	Type     string        `bson:"type"`     // 文章类型
}

SC_Post表结构

func (*SC_Post) Save

func (this *SC_Post) Save() error

保存Post数据

type SC_Redirect

type SC_Redirect struct {
	Id      bson.ObjectId `_id`
	Caption string        `bson:"caption"` // 内链名称
	Link    string        `bson:"link"`    // 跳转地址
}

SC_Redirect表结构

func (*SC_Redirect) Save

func (this *SC_Redirect) Save() error

保存内链数据

type SC_Tag

type SC_Tag struct {
	Id      bson.ObjectId `_id`
	Caption string        `bson:"caption"` // 标签名称
	Slug    string        `bson:"slug"`    // 固定链接
}

SC_Tag表结构

Jump to

Keyboard shortcuts

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