Documentation
¶
Overview ¶
数据库结构
Index ¶
- Variables
- func Count(collection *mgo.Collection, query interface{}) int
- func Delete(collection *mgo.Collection, query interface{}) error
- func GetAllByQuery(collection *mgo.Collection, query, val interface{})
- func GetDataByQuery(collection *mgo.Collection, start, length int, fields string, ...)
- func GetOneById(collection *mgo.Collection, id bson.ObjectId, val interface{})
- func GetOneByQuery(collection *mgo.Collection, query, val interface{})
- func Has(collection *mgo.Collection, query interface{}) bool
- func Insert(collection *mgo.Collection, data interface{}) error
- func SetAdd(collection *mgo.Collection, query interface{}, field string, add bool) error
- func SetOption(sitename, subtitle, keywords, description, author, email string)
- func Tag(caption, slug string) error
- func Update(collection *mgo.Collection, query, data interface{}) error
- type Conf
- type DB
- type Key
- type SC_Config
- type SC_Post
- type SC_Redirect
- type SC_Tag
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 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 SetAdd ¶
func SetAdd(collection *mgo.Collection, query interface{}, field string, add bool) 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 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表结构
Click to show internal directories.
Click to hide internal directories.