Skip to main content

Insert

postgres:

type User struct {
Id *int64
Username string
}

err = batis.Insert("users", user, batis.Returning("id")).Scan(&user.Id).Error

mysql:

r = batis.Insert("users", user, batis.Returning("id"))
err = r.Error
id = r.LastInsertId

InsertBatch

err = batis.InsertBatch("users", 10, users).Error

Nested Struct

type Id struct {
Id *int64
}

type User struct {
Id
Username string
}

err = batis.Insert("users", user, batis.Returning("id")).Scan(&user.Id).Error