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

Function ExampleDB_Model_selectSomeColumnsIntoVars

example_model_test.go:320–336  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

318}
319
320func ExampleDB_Model_selectSomeColumnsIntoVars() {
321 db := modelDB()
322
323 var id int
324 var title string
325 err := db.Model(&Book{}).
326 Column("book.id", "book.title").
327 OrderExpr("book.id ASC").
328 Limit(1).
329 Select(&id, &title)
330 if err != nil {
331 panic(err)
332 }
333
334 fmt.Println(id, title)
335 // Output: 1 book 1
336}
337
338func ExampleDB_Model_selectWhereIn() {
339 db := modelDB()

Callers

nothing calls this directly

Calls 6

modelDBFunction · 0.85
LimitMethod · 0.80
OrderExprMethod · 0.80
ColumnMethod · 0.80
ModelMethod · 0.65
SelectMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…