Company now works
This commit is contained in:
36
db/company.go
Normal file
36
db/company.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package db
|
||||
|
||||
type Company struct {
|
||||
ID int
|
||||
UUID string
|
||||
Name string
|
||||
Email string
|
||||
TaxId string
|
||||
Password string
|
||||
}
|
||||
|
||||
// InsertCompany inserts a new record into the Company table
|
||||
func InsertCompany(company Company) (int, error) {
|
||||
query := `
|
||||
INSERT INTO Company (UUID, Name, Email, TaxId, Password)
|
||||
VALUES (?, ?, ?, ?, ?)
|
||||
RETURNING id
|
||||
`
|
||||
|
||||
stmt, err := db.Prepare(query)
|
||||
if err != nil {
|
||||
return -2, err
|
||||
}
|
||||
defer stmt.Close()
|
||||
|
||||
id := 0
|
||||
err = stmt.QueryRow(
|
||||
company.UUID, company.Name, company.Email, company.TaxId, company.Password,
|
||||
).Scan(&id)
|
||||
|
||||
if err != nil {
|
||||
return -1, err
|
||||
}
|
||||
|
||||
return id, nil
|
||||
}
|
||||
Reference in New Issue
Block a user