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

Function ExampleDB_Model_selectAndCount

example_model_test.go:493–506  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

491}
492
493func ExampleDB_Model_selectAndCount() {
494 db := modelDB()
495
496 var books []Book
497 count, err := db.Model(&books).OrderExpr("id ASC").Limit(2).SelectAndCount()
498 if err != nil {
499 panic(err)
500 }
501
502 fmt.Println(count)
503 fmt.Println(books)
504 // Output: 3
505 // [Book<Id=1 Title="book 1"> Book<Id=2 Title="book 2">]
506}
507
508func ExampleDB_Model_exists() {
509 db := modelDB()

Callers

nothing calls this directly

Calls 5

modelDBFunction · 0.85
SelectAndCountMethod · 0.80
LimitMethod · 0.80
OrderExprMethod · 0.80
ModelMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…