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


Golang EntityController.LoadFromQuery方法代码示例

本文整理汇总了Golang中gitlab.com/tamasd/ab.EntityController.LoadFromQuery方法的典型用法代码示例。如果您正苦于以下问题:Golang EntityController.LoadFromQuery方法的具体用法?Golang EntityController.LoadFromQuery怎么用?Golang EntityController.LoadFromQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gitlab.com/tamasd/ab.EntityController的用法示例。


在下文中一共展示了EntityController.LoadFromQuery方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: LoadActualScreeningForWalkthrough

func LoadActualScreeningForWalkthrough(db ab.DB, ec *ab.EntityController, wid string) (*Screening, error) {
	screeningFields := ec.FieldList("screening")
	screenings, err := ec.LoadFromQuery(db, "screening", "SELECT "+screeningFields+" FROM screening s WHERE wid = $1 AND published = true ORDER BY created DESC LIMIT 1", wid)
	if err != nil {
		return nil, err
	}

	if len(screenings) != 1 {
		return nil, nil
	}

	return screenings[0].(*Screening), nil
}
开发者ID:Pronovix,项目名称:walkhub-service,代码行数:13,代码来源:screening.go

示例2: LoadActualRevision

func LoadActualRevision(db ab.DB, ec *ab.EntityController, UUID string) (*Walkthrough, error) {
	walkthroughFields := ec.FieldList("walkthrough")
	entities, err := ec.LoadFromQuery(db, "walkthrough", "SELECT "+walkthroughFields+" FROM walkthrough w WHERE UUID = $1 AND published = true ORDER BY Updated DESC LIMIT 1", UUID)

	if err != nil {
		return nil, err
	}

	if len(entities) != 1 {
		return nil, nil
	}

	return entities[0].(*Walkthrough), nil
}
开发者ID:Pronovix,项目名称:walkhub-service,代码行数:14,代码来源:walkthrough.go

示例3: LoadAllActualWalkthroughs

func LoadAllActualWalkthroughs(db ab.DB, ec *ab.EntityController, start, limit int) ([]*Walkthrough, error) {
	walkthroughFields := ec.FieldList("walkthrough")
	entities, err := ec.LoadFromQuery(db, "walkthrough", `WITH
	latestwt AS (SELECT uuid, MAX(updated) u FROM walkthrough WHERE published = true GROUP BY uuid ORDER BY u DESC),
	latestuuid AS (SELECT w.revision FROM latestwt l JOIN walkthrough w ON l.uuid = w.uuid AND l.u = w.updated)
	SELECT `+walkthroughFields+` FROM walkthrough w JOIN latestuuid l ON l.revision = w.revision ORDER BY updated DESC`)

	if err != nil {
		return []*Walkthrough{}, err
	}

	wts := make([]*Walkthrough, len(entities))
	for i, e := range entities {
		wts[i] = e.(*Walkthrough)
	}

	return wts, nil
}
开发者ID:Pronovix,项目名称:walkhub-service,代码行数:18,代码来源:walkthrough.go

示例4: LoadActualRevisions

func LoadActualRevisions(db ab.DB, ec *ab.EntityController, uuids []string) ([]*Walkthrough, error) {
	walkthroughFields := ec.FieldList("walkthrough")
	placeholders := util.GeneratePlaceholders(1, uint(len(uuids))+1)
	entities, err := ec.LoadFromQuery(db, "walkthrough", `WITH
	latestwt AS (SELECT uuid, MAX(updated) u FROM walkthrough WHERE published = true GROUP BY uuid ORDER BY u DESC),
	latestuuid AS (SELECT w.revision FROM latestwt l JOIN walkthrough w ON l.uuid = w.uuid AND l.u = w.updated)
	SELECT `+walkthroughFields+` FROM walkthrough w JOIN latestuuid l ON l.revision = w.revision WHERE w.uuid IN (`+placeholders+`)
	`, util.StringSliceToInterfaceSlice(uuids)...)

	if err != nil {
		return []*Walkthrough{}, err
	}

	wts := make([]*Walkthrough, len(entities))
	for i, e := range entities {
		wts[i] = e.(*Walkthrough)
	}

	return wts, nil
}
开发者ID:Pronovix,项目名称:walkhub-service,代码行数:20,代码来源:walkthrough.go


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