MCPcopy Create free account
hub / github.com/go-pg/pg / First

Method First

orm/query.go:812–821  ·  view source on GitHub ↗

First sorts rows by primary key and selects the first row. It is a shortcut for: q.OrderExpr("id ASC").Limit(1)

()

Source from the content-addressed store, hash-verified

810//
811// q.OrderExpr("id ASC").Limit(1)
812func (q *Query) First() error {
813 table := q.tableModel.Table()
814
815 if err := table.checkPKs(); err != nil {
816 return err
817 }
818
819 b := appendColumns(nil, table.Alias, table.PKs)
820 return q.OrderExpr(internal.BytesToString(b)).Limit(1).Select()
821}
822
823// Last sorts rows by primary key and selects the last row.
824// It is a shortcut for:

Calls 7

OrderExprMethod · 0.95
BytesToStringFunction · 0.92
appendColumnsFunction · 0.85
checkPKsMethod · 0.80
LimitMethod · 0.80
TableMethod · 0.65
SelectMethod · 0.45