Skip to content

Commit fd14f59

Browse files
committed
Basics
1 parent 9f3d8d5 commit fd14f59

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

content/docs/guides/table.md

+66
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,76 @@ From here you can execute SQL Statements against the table as follows
1414

1515
## Insert
1616

17+
We need to insert a single record to the table.
18+
19+
```java
20+
movieStore
21+
.insert()
22+
.values(new Movie(null, "Inception", "Christopher Nolan"))
23+
.execute();
24+
```
25+
26+
We need to insert multiple records to the table.
27+
28+
```
29+
movieStore
30+
.insert()
31+
.values(new Movie(null, "Pulp Fiction", "Quentin Tarantino"))
32+
.values(new Movie(null, "The Matrix", "Lana Wachowski"))
33+
.values(new Movie(null, "Dunkirk", "Christopher Nolan"))
34+
.values(new Movie(null, "Fight Club", "David Fincher"))
35+
.values(new Movie(null, "Interstellar", "Christopher Nolan"))
36+
.values(new Movie(null, "The Social Network", "David Fincher"))
37+
.execute();
38+
```
39+
40+
We need to insert a single record to the table and return inserted value.
41+
42+
```java
43+
Movie movie = movieStore
44+
.insert()
45+
.values(new Movie(null, "The Dark Knight", "Christopher Nolan"))
46+
.returning();
47+
```
48+
1749
## Select
1850

51+
We need to select all the movies
52+
53+
```java
54+
List<Movie> movies = movieStore
55+
.select()
56+
.execute();
57+
```
58+
59+
We need to select the movies with where clause
60+
61+
```java
62+
List<Movie> movies = movieStore
63+
.select()
64+
.where(directedBy().eq("Christopher Nolan"))
65+
.execute();
66+
```
67+
1968
## Update
2069

70+
Update a record
71+
72+
```java
73+
movieStore
74+
.update()
75+
.set(new Movie(null, "Fight Club", "Martyn Scorsese"))
76+
.where(title().eq("Fight Club"))
77+
.execute();
78+
```
79+
2180
## Delete
2281

82+
Delete all the records in the table
83+
84+
```java
85+
movieStore
86+
.delete()
87+
.execute();
88+
```
2389

0 commit comments

Comments
 (0)