本文整理汇总了Golang中github.com/corestoreio/csfw/storage/dbr.Session.Select方法的典型用法代码示例。如果您正苦于以下问题:Golang Session.Select方法的具体用法?Golang Session.Select怎么用?Golang Session.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/corestoreio/csfw/storage/dbr.Session
的用法示例。
在下文中一共展示了Session.Select方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: LoadByCode
func (et *TableEntityType) LoadByCode(dbrSess *dbr.Session, code string, cbs ...csdb.DbrSelectCb) error {
s, err := TableCollection.Structure(TableIndexEntityType)
if err != nil {
return errgo.Mask(err)
}
sb := dbrSess.Select(s.AllColumnAliasQuote(csdb.MainTable)...).From(s.Name, csdb.MainTable).Where("entity_type_code = ?", code)
for _, cb := range cbs {
sb = cb(sb)
}
return errgo.Mask(sb.LoadStruct(et))
}
示例2: InitEntityStoreMap
func InitEntityStoreMap(dbrSess *dbr.Session) error {
if atomic.LoadUint32(&initMapDone.done) == 1 {
return ErrStoreMapInitialized
}
initMapDone.m.Lock()
defer initMapDone.m.Unlock()
if initMapDone.done == 0 {
defer atomic.StoreUint32(&initMapDone.done, 1)
s, err := TableCollection.Structure(TableIndexEntityStore)
if err != nil {
return errgo.Mask(err)
}
var ess TableEntityStoreSlice
_, err = dbrSess.
Select(s.Columns.FieldNames()...).
From(s.Name).
LoadStructs(&ess)
if err != nil {
return errgo.Mask(err)
}
for _, es := range ess {
EntityStoreMap.Set(es.EntityTypeID, es.StoreID, es)
}
ess = ess[:len(ess)-1] // delete Struct Slice https://code.google.com/p/go-wiki/wiki/SliceTricks
return nil
}
return ErrStoreMapInitialized
}
示例3: getEntityTypeData
// getEntityTypeData retrieves all EAV models from table eav_entity_type but only those listed in variable
// codegen.ConfigEntityType. It then applies the mapping data from codegen.ConfigEntityType to the entity_type struct.
// Depends on generated code from tableToStruct.
func getEntityTypeData(dbrSess *dbr.Session) (etc eav.TableEntityTypeSlice, err error) {
s, err := eav.TableCollection.Structure(eav.TableIndexEntityType)
if err != nil {
return nil, errgo.Mask(err)
}
_, err = dbrSess.
Select(s.AllColumnAliasQuote(s.Name)...).
From(s.Name).
Where("entity_type_code IN ?", codegen.ConfigEntityType.Keys()).
LoadStructs(&etc)
if err != nil {
return nil, errgo.Mask(err)
}
for typeCode, mapData := range codegen.ConfigEntityType {
// map the fields from the config struct to the data retrieved from the database.
et, err := etc.GetByCode(typeCode)
codegen.LogFatal(err)
et.EntityModel = codegen.ParseString(mapData.EntityModel, et)
et.AttributeModel.String = codegen.ParseString(mapData.AttributeModel, et)
et.EntityTable.String = codegen.ParseString(mapData.EntityTable, et)
et.IncrementModel.String = codegen.ParseString(mapData.IncrementModel, et)
et.AdditionalAttributeTable.String = codegen.ParseString(mapData.AdditionalAttributeTable, et)
et.EntityAttributeCollection.String = codegen.ParseString(mapData.EntityAttributeCollection, et)
}
return etc, nil
}