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

Function ExampleDB_Model_selectSomeColumns

example_model_test.go:303–318  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

301}
302
303func ExampleDB_Model_selectSomeColumns() {
304 db := modelDB()
305
306 var book Book
307 err := db.Model(&book).
308 Column("book.id", "book.title").
309 OrderExpr("book.id ASC").
310 Limit(1).
311 Select()
312 if err != nil {
313 panic(err)
314 }
315
316 fmt.Println(book)
317 // Output: Book<Id=1 Title="book 1">
318}
319
320func ExampleDB_Model_selectSomeColumnsIntoVars() {
321 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…