{"id":18644727,"url":"https://github.com/xormplus/core","last_synced_at":"2025-04-11T12:31:08.537Z","repository":{"id":32476545,"uuid":"36056734","full_name":"xormplus/core","owner":"xormplus","description":null,"archived":false,"fork":false,"pushed_at":"2020-03-08T07:49:20.000Z","size":62,"stargazers_count":0,"open_issues_count":1,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T13:46:21.561Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xormplus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-05-22T06:45:58.000Z","updated_at":"2020-03-08T07:49:22.000Z","dependencies_parsed_at":"2022-08-24T22:40:29.828Z","dependency_job_id":null,"html_url":"https://github.com/xormplus/core","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xormplus%2Fcore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xormplus%2Fcore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xormplus%2Fcore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xormplus%2Fcore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xormplus","download_url":"https://codeload.github.com/xormplus/core/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248401945,"owners_count":21097328,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T06:13:23.626Z","updated_at":"2025-04-11T12:31:08.229Z","avatar_url":"https://github.com/xormplus.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"Core is a lightweight wrapper of sql.DB.\n\n# Open\n```Go\ndb, _ := core.Open(db, connstr)\n```\n\n# SetMapper\n```Go\ndb.SetMapper(SameMapper())\n```\n\n## Scan usage\n\n### Scan\n```Go\nrows, _ := db.Query()\nfor rows.Next() {\n    rows.Scan()\n}\n```\n\n### ScanMap\n```Go\nrows, _ := db.Query()\nfor rows.Next() {\n    rows.ScanMap()\n```\n\n### ScanSlice\n\nYou can use `[]string`, `[][]byte`, `[]interface{}`, `[]*string`, `[]sql.NullString` to ScanSclice. Notice, slice's length should be equal or less than select columns.\n\n```Go\nrows, _ := db.Query()\ncols, _ := rows.Columns()\nfor rows.Next() {\n    var s = make([]string, len(cols))\n    rows.ScanSlice(\u0026s)\n}\n```\n\n```Go\nrows, _ := db.Query()\ncols, _ := rows.Columns()\nfor rows.Next() {\n    var s = make([]*string, len(cols))\n    rows.ScanSlice(\u0026s)\n}\n```\n\n### ScanStruct\n```Go\nrows, _ := db.Query()\nfor rows.Next() {\n    rows.ScanStructByName()\n    rows.ScanStructByIndex()\n}\n```\n\n## Query usage\n```Go\nrows, err := db.Query(\"select * from table where name = ?\", name)\n\nuser = User{\n    Name:\"lunny\",\n}\nrows, err := db.QueryStruct(\"select * from table where name = ?Name\",\n            \u0026user)\n\nvar user = map[string]interface{}{\n    \"name\": \"lunny\",\n}\nrows, err = db.QueryMap(\"select * from table where name = ?name\",\n            \u0026user)\n```\n\n## QueryRow usage\n```Go\nrow := db.QueryRow(\"select * from table where name = ?\", name)\n\nuser = User{\n    Name:\"lunny\",\n}\nrow := db.QueryRowStruct(\"select * from table where name = ?Name\",\n            \u0026user)\n\nvar user = map[string]interface{}{\n    \"name\": \"lunny\",\n}\nrow = db.QueryRowMap(\"select * from table where name = ?name\",\n            \u0026user)\n```\n\n## Exec usage\n```Go\ndb.Exec(\"insert into user (`name`, title, age, alias, nick_name,created) values (?,?,?,?,?,?)\", name, title, age, alias...)\n\nuser = User{\n    Name:\"lunny\",\n    Title:\"test\",\n    Age: 18,\n}\nresult, err = db.ExecStruct(\"insert into user (`name`, title, age, alias, nick_name,created) values (?Name,?Title,?Age,?Alias,?NickName,?Created)\",\n            \u0026user)\n\nvar user = map[string]interface{}{\n    \"Name\": \"lunny\",\n    \"Title\": \"test\",\n    \"Age\": 18,\n}\nresult, err = db.ExecMap(\"insert into user (`name`, title, age, alias, nick_name,created) values (?Name,?Title,?Age,?Alias,?NickName,?Created)\",\n            \u0026user)\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxormplus%2Fcore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxormplus%2Fcore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxormplus%2Fcore/lists"}