本文整理匯總了Golang中github.com/couchbaselabs/sync_gateway/base.Bucket.GetName方法的典型用法代碼示例。如果您正苦於以下問題:Golang Bucket.GetName方法的具體用法?Golang Bucket.GetName怎麽用?Golang Bucket.GetName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/couchbaselabs/sync_gateway/base.Bucket
的用法示例。
在下文中一共展示了Bucket.GetName方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: addDatabase
// Adds a database to the serverContext given its Bucket.
func (sc *serverContext) addDatabase(bucket base.Bucket, dbName string, syncFun *string, nag bool) (*context, error) {
if dbName == "" {
dbName = bucket.GetName()
}
if match, _ := regexp.MatchString(`^[a-z][-a-z0-9_$()+/]*$`, dbName); !match {
return nil, fmt.Errorf("Illegal database name: %s", dbName)
}
if sc.databases[dbName] != nil {
return nil, fmt.Errorf("Duplicate database name %q", dbName)
}
dbcontext, err := db.NewDatabaseContext(dbName, bucket)
if err != nil {
return nil, err
}
if syncFun != nil {
if err := dbcontext.ApplySyncFun(*syncFun); err != nil {
return nil, err
}
}
if dbcontext.ChannelMapper == nil {
if nag {
base.Warn("Sync function undefined; using default")
}
// Always have a channel mapper object even if it does nothing:
dbcontext.ChannelMapper, _ = channels.NewDefaultChannelMapper()
}
c := &context{
dbcontext: dbcontext,
auth: dbcontext.Authenticator(),
}
sc.databases[dbName] = c
return c, nil
}