本文整理汇总了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
}
示例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
}
示例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
}
示例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
}