-
Notifications
You must be signed in to change notification settings - Fork 0
/
01-create.golo
60 lines (48 loc) · 1.14 KB
/
01-create.golo
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
module create
import artemia.redis
----
id is mandatory for "artemia model"
----
struct human = {
id
, firstName
, lastName
}
struct animal = {
id, name, species
}
----
redis helper
----
struct redisHelper = {
db, models, model
}
augment redisHelper with jedisCollection
----
Create some humans
run it:
golo golo --classpath jars/*.jar --files imports/artemia.jedis.collection.golo 01-create.golo
----
function main = |args| {
let redis = jedis("localhost", 6379)
let humansCollection =
redisHelper()
: model(human())
: db(redis)
let animalsCollection =
redisHelper()
: model(animal())
: db(redis)
let bob = human(id="bob_morane", firstName="Bob", lastName="Morane")
let john = human(id="john_doe", firstName="John", lastName="Doe")
let jane = human(id="jane_doe", firstName="Jane", lastName="Doe")
let wolf = animal("wolf", "Wolf", "dog")
let pinky = animal("pinky", "Pinky", "pig")
humansCollection: save(bob)
humansCollection: save(john)
humansCollection: save(jane)
println("all humans are saved")
animalsCollection: save(wolf)
animalsCollection: save(pinky)
println("all animals are saved")
}