forked from ulule/loukoum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
doc.go
66 lines (66 loc) · 2.47 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 loukoum provides a simple SQL Query Builder.
// At the moment, only PostgreSQL is supported.
//
// If you have to generate complex queries, which rely on various contexts, loukoum is the right tool for you.
// It helps you generate SQL queries from composable parts.
// However, keep in mind it's not an ORM or a Mapper so you have to use a SQL connector
// (like "database/sql" or "sqlx", for example) to execute queries.
//
// If you're afraid to slip a tiny SQL injection manipulating fmt (or a byte buffer...) when you append
// conditions, loukoum is here to protect you against yourself.
//
// For further informations, you can read this documentation:
// https://github.com/DzananGanic/loukoum/blob/master/README.md
//
// Or you can discover loukoum with these examples.
// An "insert" can be generated like that:
//
// builder := loukoum.Insert("comments").
// Set(
// loukoum.Pair("email", comment.Email),
// loukoum.Pair("status", "waiting"),
// loukoum.Pair("message", comment.Message),
// loukoum.Pair("created_at", loukoum.Raw("NOW()")),
// ).
// Returning("id")
//
// Also, if you need an upsert, you can define a "on conflict" clause:
//
// builder := loukoum.Insert("comments").
// Set(
// loukoum.Pair("email", comment.Email),
// loukoum.Pair("status", "waiting"),
// loukoum.Pair("message", comment.Message),
// loukoum.Pair("created_at", loukoum.Raw("NOW()")),
// ).
// OnConflict("email", loukoum.DoUpdate(
// loukoum.Pair("message", comment.Message),
// loukoum.Pair("status", "waiting"),
// loukoum.Pair("created_at", loukoum.Raw("NOW()")),
// loukoum.Pair("deleted_at", nil),
// )).
// Returning("id")
//
// Updating a news is also simple:
//
// builder := loukoum.Update("news").
// Set(
// loukoum.Pair("published_at", loukoum.Raw("NOW()")),
// loukoum.Pair("status", "published"),
// ).
// Where(loukoum.Condition("id").Equal(news.ID)).
// And(loukoum.Condition("deleted_at").IsNull(true)).
// Returning("published_at")
//
// You can remove a specific user:
//
// builder := loukoum.Delete("users").
// Where(loukoum.Condition("id").Equal(user.ID))
//
// Or select a list of users...
//
// builder := loukoum.Select("id", "first_name", "last_name", "email").
// From("users").
// Where(loukoum.Condition("deleted_at").IsNull(true))
//
package loukoum