From 0a25d6daeab19cac7e1bcd6ce42c4d5266133cc0 Mon Sep 17 00:00:00 2001 From: liujian Date: Fri, 7 Jun 2024 17:51:22 +0800 Subject: [PATCH] Update xsql QueryFirst() --- src/xsql/README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/xsql/README.md b/src/xsql/README.md index 5b4042c..568fe1b 100644 --- a/src/xsql/README.md +++ b/src/xsql/README.md @@ -58,6 +58,18 @@ bar := rows[0].Get("bar").Time() // time.Time val := rows[0].Get("bar").Value() // interface{} ``` +```go +row, err := DB.QueryFirst("SELECT * FROM xsql WHERE id = ?", 1) +if err != nil { + log.Fatal(err) +} + +id := row.Get("id").Int() +foo := row.Get("foo").String() +bar := row.Get("bar").Time() // time.Time +val := row.Get("bar").Value() // interface{} +``` + ### Mapping Of course, you can also map usage like `gorm`, `xorm`.