04-databases/blog cleanup

This commit is contained in:
programarivm 2019-09-27 11:21:17 +01:00
parent 8605bb4bc6
commit 04f454ca59
3 changed files with 69 additions and 15 deletions

View File

@ -3,4 +3,4 @@ drop()
k ^comments; k ^comments;
k ^posts; k ^posts;
k ^users; k ^users;
q q 1

View File

@ -3,44 +3,70 @@
s ok=$$set^UserRoutines(1,"alice~password~alice-jones@no-reply.com~Alice Jones") s ok=$$set^UserRoutines(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^UserRoutines(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
. w "Whoops! The user could not be created.",!,! . w "Whoops! The user could not be created.",!
; create posts ; create posts
s ok=$$set^PostRoutines(1,"lorem-ipsum~Lorem ipsum~Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.~1") s ok=$$set^PostRoutines(1,"lorem-ipsum~Lorem ipsum~Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.~1")
i ok=1 d i ok=1 d
. w "Post successfully created!",!,! . w "Post successfully created!",!
e d e d
. w "Whoops! The post could not be created.",!,! . w "Whoops! The post could not be created.",!
s ok=$$set^PostRoutines(2,"excepteur-sint-occaecat~Excepteur sint occaecat~Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.~2") s ok=$$set^PostRoutines(2,"excepteur-sint-occaecat~Excepteur sint occaecat~Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.~2")
i ok=1 d i ok=1 d
. w "Post successfully created!",!,! . w "Post successfully created!",!
e d e d
. w "Whoops! The post could not be created.",!,! . w "Whoops! The post could not be created.",!
; create comments ; create comments
s ok=$$set^CommentRoutines(1,"This is awesome. Thank you.~1") s ok=$$set^CommentRoutines(1,"This is awesome. Thank you.~1")
i ok=1 d i ok=1 d
. w "Comment successfully created!",!,! . w "Comment successfully created!",!
e d e d
. w "Whoops! The comment could not be created.",!,! . w "Whoops! The comment could not be created.",!
s ok=$$set^CommentRoutines(2,".Thank you so much for sharing this.~2") s ok=$$set^CommentRoutines(2,"Thank you so much for sharing this.~2")
i ok=1 d i ok=1 d
. w "Comment successfully created!",!,! . w "Comment successfully created!",!
e d e d
. w "Whoops! The comment could not be created.",!,! . w "Whoops! The comment could not be created.",!
; fetch a post
s ok=$$fetch^PostRoutines(1,.data)
i ok=1 d
. w !,"Post successfully fetched!",!
. w "slug: ",data("slug"),!
. w "title: ",data("title"),!
. w "description: ",data("description"),!
. w "id_user: ",data("id_user"),!
e d
. w "Whoops! The post could not be fetched.",!
; fetch a post
s ok=$$fetch^CommentRoutines(2,.data)
i ok=1 d
. w !,"Comment successfully fetched!",!
. w "description: ",data("description"),!
. w "id_post: ",data("id_post"),!,!
e d
. w "Whoops! The post could not be fetched.",!
; drop database ; drop database
d drop^DatabaseRoutines s ok=$$drop^DatabaseRoutines()
i ok=1 d
. w "Database successfully dropped!",!
e d
. w "Whoops! The database could not be dropped.",!

View File

@ -225,6 +225,34 @@ Copy the examples into your `~/.fis-gtm/V6.3-003A_x86_64/r` folder and run:
> For further details also visit [UserRoutines.m](https://github.com/programarivm/mumps-examples/blob/master/04-databases/simple-crud/UserRoutines.m) > For further details also visit [UserRoutines.m](https://github.com/programarivm/mumps-examples/blob/master/04-databases/simple-crud/UserRoutines.m)
### [`blog/Main.m`](https://github.com/programarivm/mumps-examples/blob/master/04-databases/blog/Main.m)
User successfully created!
User successfully created!
Post successfully created!
Post successfully created!
Comment successfully created!
Comment successfully created!
Post successfully fetched!
slug: lorem-ipsum
title: Lorem ipsum
description: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
id_user: 1
Comment successfully fetched!
description: Thank you so much for sharing this.
id_post: 2
Database successfully dropped!
For further details also visit:
- [`CommentRoutines.m`](https://github.com/programarivm/mumps-examples/blob/master/04-databases/blog/CommentRoutines.m)
- [`DatabaseRoutines.m`](https://github.com/programarivm/mumps-examples/blob/master/04-databases/blog/DatabaseRoutines.m)
- [`PostRoutines.m`](https://github.com/programarivm/mumps-examples/blob/master/04-databases/blog/PostRoutines.m)
- [`UserRoutines.m`](https://github.com/programarivm/mumps-examples/blob/master/04-databases/blog/UserRoutines.m)
--- ---
### Contributions ### Contributions