You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 11, 2021. It is now read-only.
Copy file name to clipboardExpand all lines: doc/docs/blog/golang/using-redisql-with-golang.md
+10-6Lines changed: 10 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,11 +28,13 @@ if err != nil {
28
28
29
29
## Setting up the database
30
30
31
-
In order to work with RediSQL is necessary to do a small setup. The first step is always to create a database, then we create the tables inside the databases and finally the different statements if they are necessary.
31
+
In order to work with RediSQL is necessary to do a small setup.
32
+
The first step is always to create a database, then we create the tables inside the databases and finally the different statements if they are necessary.
32
33
33
-
It is always a good idea to use statements instead of building query by hand. but it is not mandatory. The use of statements eliminate the risk of SQL injection and it is more performant, since the query is parsed only once and not every time it get executed.
34
+
It is always a good idea to use statements instead of building query by hand, but it is not mandatory.
35
+
The use of statements eliminate the risk of SQL injection and it is more performant, since the query is parsed only once and not every time it get executed.
34
36
35
-
In our case we create a simple database,`HN`.
37
+
In our case we create a simple database that we will call`HN`.
The statement is a little complex. It exploit the [JSON1][json1] sqlite extension to extract the necessary fields from a JSON string. In particular we extract the `id`, the `by` (author) and the `time` fields.
63
+
The statement is a little complex.
64
+
It exploit the [JSON1][json1] sqlite extension to extract the necessary fields from a JSON string.
65
+
In particular we extract the `id`, the `by` (author) and the `time` fields.
62
66
63
67
After that those fields are extracted from the JSON string we store all of them into the database along with the whole item.
64
68
@@ -83,7 +87,7 @@ go func() {
83
87
}()
84
88
```
85
89
86
-
The `getMaxItem()` function is implemented as:
90
+
The API provide an endpoint that show the biggest element in HN at the moment, it is a simple auto-incremental id that we can fetch using the `getMaxItem()` function implemented as:
87
91
88
92
```golang
89
93
funcgetMaxItem() int {
@@ -150,7 +154,7 @@ Feel free to explore our [references documentation][ref] to understand better wh
150
154
151
155
The complete code of this example is [available here.](https://github.com/RedBeardLab/rediSQL/blob/master/doc/docs/blog/golang/main.go)
152
156
153
-
157
+
If you wish to see a similar tutorial for a different language, [open an issue on github.](https://github.com/RedBeardLab/rediSQL/issues/new)
0 commit comments