当前位置: 首页>>代码示例>>Golang>>正文


Golang dbr.Session类代码示例

本文整理汇总了Golang中github.com/corestoreio/csfw/storage/dbr.Session的典型用法代码示例。如果您正苦于以下问题:Golang Session类的具体用法?Golang Session怎么用?Golang Session使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Session类的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))
}
开发者ID:bom-d-van,项目名称:csfw,代码行数:11,代码来源:entity_type.go

示例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
}
开发者ID:joao-parana,项目名称:csfw,代码行数:32,代码来源:entity_store.go

示例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
}
开发者ID:hafeez3000,项目名称:csfw,代码行数:33,代码来源:entity_type.go


注:本文中的github.com/corestoreio/csfw/storage/dbr.Session类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。