本文整理匯總了Golang中github.com/corestoreio/csfw/store.TableWebsiteSlice.Load方法的典型用法代碼示例。如果您正苦於以下問題:Golang TableWebsiteSlice.Load方法的具體用法?Golang TableWebsiteSlice.Load怎麽用?Golang TableWebsiteSlice.Load使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/corestoreio/csfw/store.TableWebsiteSlice
的用法示例。
在下文中一共展示了TableWebsiteSlice.Load方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: getAttributeValuesForWebsites
// getAttributeValuesForWebsites creates a map where the key is the attribute ID and
// each part of the StringEntities slice are the full attribute values for a website ID.
func getAttributeValuesForWebsites(ctx *context) map[string][]codegen.StringEntities {
var tws store.TableWebsiteSlice
tws.Load(ctx.dbrConn.NewSession(nil), func(sb *dbr.SelectBuilder) *dbr.SelectBuilder {
return sb.Where("website_id > 0")
})
// key contains the attributeID as a string
var aws = make(map[string][]codegen.StringEntities)
tew, err := ctx.aat.TableEavWebsite()
codegen.LogFatal(err)
if tew != nil { // only for those who have a wbesite specific table
for _, w := range tws {
aCollection, err := codegen.LoadStringEntities(ctx.db, getAttrSelect(ctx, w.WebsiteID))
codegen.LogFatal(err)
for _, row := range aCollection {
if aid, ok := row["attribute_id"]; ok {
if nil == aws[aid] {
aws[aid] = make([]codegen.StringEntities, 0, 200) // up to 200 websites at once
}
aws[aid] = append(aws[aid], row)
} else {
codegen.LogFatal(errgo.Newf("Column attribute_id not found in collection %#v\n", aCollection))
}
}
}
}
return aws
}
示例2: TestTableWebsiteSliceLoad
func TestTableWebsiteSliceLoad(t *testing.T) {
db := csdb.MustConnectTest()
defer db.Close()
dbrSess := dbr.NewConnection(db, nil).NewSession(nil)
var websites store.TableWebsiteSlice
websites.Load(dbrSess)
assert.True(t, websites.Len() > 2)
for _, s := range websites {
assert.True(t, len(s.Code.String) > 1)
}
}