-
Notifications
You must be signed in to change notification settings - Fork 1
/
doc.go
66 lines (66 loc) · 1.87 KB
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Package makroud provides a high level SQL Connector.
// At the moment, only PostgreSQL is supported.
//
// It's an advanced mapper and/or a lightweight ORM that relies on reflection.
//
// For further informations, you can read this documentation:
// https://github.com/ulule/makroud/blob/master/README.md
//
// Or you can discover makroud with these examples.
// First, you have to create a driver:
//
// driver, err := makroud.New(
// makroud.Host(cfg.Host),
// makroud.Port(cfg.Port),
// makroud.User(cfg.User),
// makroud.Password(cfg.Password),
// makroud.Database(cfg.Name),
// makroud.SSLMode(cfg.SSLMode),
// makroud.MaxOpenConnections(cfg.MaxOpenConnections),
// makroud.MaxIdleConnections(cfg.MaxIdleConnections),
// )
//
// Then, define a model:
//
// type User struct {
// ID string `makroud:"column:id,pk:ulid"`
// Email string `makroud:"column:email"`
// Password string `makroud:"column:password"`
// Country string `makroud:"column:country"`
// Locale string `makroud:"column:locale"`
// }
//
// Execute an insert:
//
// user := &User{
// Email: "[email protected]",
// Password: "019a7bdf56b9f48e18096d62b21f",
// Country: "FR",
// Locale: "fr",
// }
//
// err := makroud.Save(ctx, driver, user)
//
// Or an update:
//
// user.Email = "[email protected]"
//
// err := makroud.Save(ctx, driver, user)
//
// Or execute a simple query without model:
//
// import "github.com/ulule/loukoum/v3"
//
// list := []string{}
//
// stmt := loukoum.Update("users").
// Set(
// loukoum.Pair("updated_at", loukoum.Raw("NOW()")),
// loukoum.Pair("status", status),
// ).
// Where(loukoum.Condition("group_id").Equal(gid)).
// Returning("id")
//
// err := makroud.Exec(ctx, driver, stmt, &list)
//
package makroud