Skip to content

Commit

Permalink
beego tests
Browse files Browse the repository at this point in the history
  • Loading branch information
egregius313 committed Jan 10, 2025
1 parent de62796 commit 16c84f7
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"fmt"

beegoOrm "github.com/beego/beego/orm"
gocb "github.com/couchbase/gocb/v2"
"github.com/gogf/gf/database/gdb"
"github.com/rqlite/gorqlite"
Expand Down Expand Up @@ -33,18 +32,6 @@ func gogf(g gdb.DB) {
fmt.Println(u1)
}

func beego() {
orm := beegoOrm.NewOrm()

type User struct {
Id int
Name string
}

var user User
orm.Read(&user) // $source
}

func couchbase(coll *gocb.Collection) {
type User struct {
Name string
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package test

import (
"github.com/beego/beego/v2/client/orm"
)

func test_DB(db orm.DB) {
rows, err := db.Query("SELECT * FROM users") // $ source
ignore(rows, err)

rows, err = db.QueryContext(nil, "SELECT * FROM users") // $ source
ignore(rows, err)

row := db.QueryRow("SELECT * FROM users") // $ source
ignore(row)

row = db.QueryRowContext(nil, "SELECT * FROM users") // $ source
ignore(row)
}

func test_DQL() {
o := orm.NewOrm()
o.Read(&User{}) // $ source
o.ReadWithCtx(nil, &User{}) // $ source
o.ReadForUpdate(&User{}) // $ source
o.ReadForUpdateWithCtx(nil, &User{}) // $ source
o.ReadOrCreate(&User{}, "name") // $ source
o.ReadOrCreateWithCtx(nil, &User{}, "name") // $ source
}

0 comments on commit 16c84f7

Please sign in to comment.