This commit is contained in:
programarivm 2019-09-27 21:06:39 +01:00
parent 5a0650ec2b
commit f034aacb24
10 changed files with 72 additions and 72 deletions

View File

@ -1,56 +0,0 @@
; 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.")
; 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.")
; fetch posts by post
do fetch^PostRoutines(1,.data)
w "Post fetched:",!
w "slug: ",data("slug"),!
w "title: ",data("title"),!
w "description: ",data("description"),!
do fetch^PostRoutines(2,.data)
w !,"Post fetched:",!
w "slug: ",data("slug"),!
w "title: ",data("title"),!
w "description: ",data("description"),!
; fetch posts by user
do fetchByUser^PostRoutines(1,.data)
w !,"Posts fetched by user:",!
w data(1),!
w data(2),!
; fetch comments
do fetch^CommentRoutines(1,.data)
w !,"Comment fetched:",!
w "description: ",data("description"),!
do fetch^CommentRoutines(2,.data)
w !,"Comment fetched:",!
w "description: ",data("description"),!
; drop database
s ok=$$drop^DatabaseRoutines()
i ok=1 d
. w !,"Database successfully dropped!",!
e d
. w "Whoops! The database could not be dropped.",!

View File

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

View File

@ -1,13 +1,13 @@
; create users ; create users
s ok=$$set^UserRoutines(1,"alice~password~alice-jones@no-reply.com~Alice Jones") s ok=$$set^User(1,"alice~password~alice-jones@no-reply.com~Alice Jones")
i ok=1 d i ok=1 d
. w "User successfully created!",! . w "User successfully created!",!
e d e d
. w "Whoops! The user could not be created.",! . w "Whoops! The user could not be created.",!
s ok=$$set^UserRoutines(2,"bob~password~bob-smith@no-reply.com~Bob Smith") s ok=$$set^User(2,"bob~password~bob-smith@no-reply.com~Bob Smith")
i ok=1 d i ok=1 d
. w "User successfully created!",! . w "User successfully created!",!
e d e d
@ -15,7 +15,7 @@
; fetch a user ; fetch a user
s ok=$$fetch^UserRoutines(1,.data) s ok=$$fetch^User(1,.data)
i ok=1 d i ok=1 d
. w !,"User successfully fetched!",! . w !,"User successfully fetched!",!
. w "username: ",data("username"),! . w "username: ",data("username"),!
@ -26,7 +26,7 @@
; update a user ; update a user
s ok=$$set^UserRoutines(1,"amelia~password~amelia-roberts@no-reply.com~Amelia Roberts") s ok=$$set^User(1,"amelia~password~amelia-roberts@no-reply.com~Amelia Roberts")
i ok=1 d i ok=1 d
. w !,"User successfully updated!",! . w !,"User successfully updated!",!
e d e d
@ -34,7 +34,7 @@
; fetch a user ; fetch a user
s ok=$$fetch^UserRoutines(1,.data) s ok=$$fetch^User(1,.data)
i ok=1 d i ok=1 d
. w !,"User successfully fetched!",! . w !,"User successfully fetched!",!
. w "username: ",data("username"),! . w "username: ",data("username"),!
@ -45,7 +45,7 @@
; delete a user ; delete a user
s ok=$$remove^UserRoutines(2) s ok=$$remove^User(2)
i ok=1 d i ok=1 d
. w !,"User successfully deleted!",! . w !,"User successfully deleted!",!
e d e d
@ -53,7 +53,7 @@
; fetch a user ; fetch a user
s ok=$$fetch^UserRoutines(2,.data) s ok=$$fetch^User(2,.data)
i ok=1 d i ok=1 d
. w !,"User successfully fetched!",! . w !,"User successfully fetched!",!
. w "username: ",data("username"),! . w "username: ",data("username"),!
@ -64,7 +64,7 @@
; drop database ; drop database
s ok=$$drop^DatabaseRoutines() s ok=$$drop^Database()
i ok=1 d i ok=1 d
. w !,"Database successfully dropped!",! . w !,"Database successfully dropped!",!
e d e d

View File

@ -196,7 +196,7 @@ Copy the examples into your `~/.fis-gtm/V6.3-003A_x86_64/r` folder and run:
$data(^gtree(0,0,0,0,0)) is 0 $data(^gtree(0,0,0,0,0)) is 0
$data(^gtree(0)) is 0 $data(^gtree(0)) is 0
### [`basic-crud/Main.m`](https://github.com/programarivm/mumps-examples/blob/master/04-databases/basic-crud/Main.m) ### [`basic-sql-crud/Main.m`](https://github.com/programarivm/mumps-examples/blob/master/04-databases/basic-sql-crud/Main.m)
User successfully created! User successfully created!
User successfully created! User successfully created!
@ -224,10 +224,10 @@ Copy the examples into your `~/.fis-gtm/V6.3-003A_x86_64/r` folder and run:
For further details also visit: For further details also visit:
- [`DatabaseRoutines.m`](https://github.com/programarivm/mumps-examples/blob/master/04-databases/basic-crud/DatabaseRoutines.m) - [`Database.m`](https://github.com/programarivm/mumps-examples/blob/master/04-databases/basic-sql-crud/routines/Database.m)
- [`UserRoutines.m`](https://github.com/programarivm/mumps-examples/blob/master/04-databases/basic-crud/UserRoutines.m) - [`User.m`](https://github.com/programarivm/mumps-examples/blob/master/04-databases/basic-sql-crud/routines/User.m)
### [`basic-blog/Main.m`](https://github.com/programarivm/mumps-examples/blob/master/04-databases/basic-blog/Main.m) ### [`basic-sql-blog/Main.m`](https://github.com/programarivm/mumps-examples/blob/master/04-databases/basic-sql-blog/Main.m)
Post fetched: Post fetched:
slug: lorem-ipsum slug: lorem-ipsum
@ -253,10 +253,10 @@ For further details also visit:
For further details also visit: For further details also visit:
- [`CommentRoutines.m`](https://github.com/programarivm/mumps-examples/blob/master/04-databases/basic-blog/CommentRoutines.m) - [`Comment.m`](https://github.com/programarivm/mumps-examples/blob/master/04-databases/basic-sql-blog/routines/Comment.m)
- [`DatabaseRoutines.m`](https://github.com/programarivm/mumps-examples/blob/master/04-databases/basic-blog/DatabaseRoutines.m) - [`Database.m`](https://github.com/programarivm/mumps-examples/blob/master/04-databases/basic-sql-blog/routines/Database.m)
- [`PostRoutines.m`](https://github.com/programarivm/mumps-examples/blob/master/04-databases/basic-blog/PostRoutines.m) - [`Post.m`](https://github.com/programarivm/mumps-examples/blob/master/04-databases/basic-sql-blog/routines/Post.m)
- [`UserRoutines.m`](https://github.com/programarivm/mumps-examples/blob/master/04-databases/basic-blog/UserRoutines.m) - [`User.m`](https://github.com/programarivm/mumps-examples/blob/master/04-databases/basic-sql-blog/routines/User.m)
--- ---