mumps-demo/04-databases/basic-blog/Main.m

57 lines
1.8 KiB
Mathematica
Raw Normal View History

2019-09-27 05:54:25 -04:00
; create users
s ok=$$set^UserRoutines(1,"alice~password~alice-jones@no-reply.com~Alice Jones")
s ok=$$set^UserRoutines(2,"bob~password~bob-smith@no-reply.com~Bob Smith")
; create posts
s ok=$$set^PostRoutines(1,1,"lorem-ipsum~Lorem ipsum~Lorem ipsum dolor sit amet, consectetuer adipiscing elit.")
s ok=$$set^PostRoutines(2,1,"donec-pede-justo~Donec pede justo~Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu.")
s ok=$$set^PostRoutines(3,2,"curabitur-ullamcorper-ultricies~Curabitur ullamcorper ultricies~ Curabitur ullamcorper ultricies nisi.")
s ok=$$set^PostRoutines(4,2,"donec-vitae-sapien~Donec vitae sapien~Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante.")
2019-09-27 05:54:25 -04:00
; create comments
s ok=$$set^CommentRoutines(1,1,"This is awesome! Thank you.")
s ok=$$set^CommentRoutines(2,2,"Thank you so much for sharing this.")
2019-09-27 05:54:25 -04:00
2019-09-27 13:48:25 -04:00
; fetch posts by post
2019-09-27 06:21:17 -04:00
do fetchByPost^PostRoutines(1,.data)
2019-09-27 13:48:25 -04:00
w "Post fetched by post:",!
w "slug: ",data("slug"),!
w "title: ",data("title"),!
w "description: ",data("description"),!
2019-09-27 06:21:17 -04:00
do fetchByPost^PostRoutines(2,.data)
2019-09-27 13:48:25 -04:00
w !,"Post fetched by post:",!
w "slug: ",data("slug"),!
w "title: ",data("title"),!
w "description: ",data("description"),!
2019-09-27 06:21:17 -04:00
2019-09-27 13:48:25 -04:00
; fetch posts by user
do fetchByUser^PostRoutines(1,.data)
w !,"Posts fetched by user:",!
w data(1),!
w data(2),!
; fetch comments
2019-09-27 06:21:17 -04:00
do fetchByComment^CommentRoutines(1,.data)
2019-09-27 13:48:25 -04:00
w !,"Comment fetched by comment:",!
w "description: ",data("description"),!
do fetchByComment^CommentRoutines(2,.data)
2019-09-27 13:48:25 -04:00
w !,"Comment fetched by comment:",!
w "description: ",data("description"),!
2019-09-27 05:54:25 -04:00
; drop database
2019-09-27 06:21:17 -04:00
s ok=$$drop^DatabaseRoutines()
i ok=1 d
. w !,"Database successfully dropped!",!
2019-09-27 06:21:17 -04:00
e d
. w "Whoops! The database could not be dropped.",!