From 04f454ca591c87fdea0060243dafd93ccaebc0c2 Mon Sep 17 00:00:00 2001 From: programarivm Date: Fri, 27 Sep 2019 11:21:17 +0100 Subject: [PATCH] 04-databases/blog cleanup --- 04-databases/blog/DatabaseRoutines.m | 2 +- 04-databases/blog/Main.m | 54 ++++++++++++++++++++-------- README.md | 28 +++++++++++++++ 3 files changed, 69 insertions(+), 15 deletions(-) diff --git a/04-databases/blog/DatabaseRoutines.m b/04-databases/blog/DatabaseRoutines.m index 81749ee..b10163c 100644 --- a/04-databases/blog/DatabaseRoutines.m +++ b/04-databases/blog/DatabaseRoutines.m @@ -3,4 +3,4 @@ drop() k ^comments; k ^posts; k ^users; - q + q 1 diff --git a/04-databases/blog/Main.m b/04-databases/blog/Main.m index dbd280f..b9bc912 100644 --- a/04-databases/blog/Main.m +++ b/04-databases/blog/Main.m @@ -3,44 +3,70 @@ s ok=$$set^UserRoutines(1,"alice~password~alice-jones@no-reply.com~Alice Jones") i ok=1 d - . w "User successfully created!",!,! + . w "User successfully created!",! 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") i ok=1 d - . w "User successfully created!",!,! + . w "User successfully created!",! e d - . w "Whoops! The user could not be created.",!,! + . w "Whoops! The user could not be created.",! ; 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") i ok=1 d - . w "Post successfully created!",!,! + . w "Post successfully created!",! 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") i ok=1 d - . w "Post successfully created!",!,! + . w "Post successfully created!",! e d - . w "Whoops! The post could not be created.",!,! + . w "Whoops! The post could not be created.",! ; create comments s ok=$$set^CommentRoutines(1,"This is awesome. Thank you.~1") i ok=1 d - . w "Comment successfully created!",!,! + . w "Comment successfully created!",! 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 - . w "Comment successfully created!",!,! + . w "Comment successfully created!",! 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 - 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.",! diff --git a/README.md b/README.md index 409d9bf..a16717a 100644 --- a/README.md +++ b/README.md @@ -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) +### [`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