diff --git a/04-databases/basic-blog/Main.m b/04-databases/basic-blog/Main.m deleted file mode 100644 index cf410d8..0000000 --- a/04-databases/basic-blog/Main.m +++ /dev/null @@ -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.",! diff --git a/04-databases/basic-sql-blog/Main.m b/04-databases/basic-sql-blog/Main.m new file mode 100644 index 0000000..7daa529 --- /dev/null +++ b/04-databases/basic-sql-blog/Main.m @@ -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.",! diff --git a/04-databases/basic-blog/CommentRoutines.m b/04-databases/basic-sql-blog/routines/Comment.m similarity index 100% rename from 04-databases/basic-blog/CommentRoutines.m rename to 04-databases/basic-sql-blog/routines/Comment.m diff --git a/04-databases/basic-blog/DatabaseRoutines.m b/04-databases/basic-sql-blog/routines/Database.m similarity index 100% rename from 04-databases/basic-blog/DatabaseRoutines.m rename to 04-databases/basic-sql-blog/routines/Database.m diff --git a/04-databases/basic-blog/PostRoutines.m b/04-databases/basic-sql-blog/routines/Post.m similarity index 100% rename from 04-databases/basic-blog/PostRoutines.m rename to 04-databases/basic-sql-blog/routines/Post.m diff --git a/04-databases/basic-blog/UserRoutines.m b/04-databases/basic-sql-blog/routines/User.m similarity index 100% rename from 04-databases/basic-blog/UserRoutines.m rename to 04-databases/basic-sql-blog/routines/User.m diff --git a/04-databases/basic-crud/Main.m b/04-databases/basic-sql-crud/Main.m similarity index 75% rename from 04-databases/basic-crud/Main.m rename to 04-databases/basic-sql-crud/Main.m index 675f1cc..2f80569 100644 --- a/04-databases/basic-crud/Main.m +++ b/04-databases/basic-sql-crud/Main.m @@ -1,13 +1,13 @@ ; 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 . w "User successfully created!",! e d . 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 . w "User successfully created!",! e d @@ -15,7 +15,7 @@ ; fetch a user - s ok=$$fetch^UserRoutines(1,.data) + s ok=$$fetch^User(1,.data) i ok=1 d . w !,"User successfully fetched!",! . w "username: ",data("username"),! @@ -26,7 +26,7 @@ ; 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 . w !,"User successfully updated!",! e d @@ -34,7 +34,7 @@ ; fetch a user - s ok=$$fetch^UserRoutines(1,.data) + s ok=$$fetch^User(1,.data) i ok=1 d . w !,"User successfully fetched!",! . w "username: ",data("username"),! @@ -45,7 +45,7 @@ ; delete a user - s ok=$$remove^UserRoutines(2) + s ok=$$remove^User(2) i ok=1 d . w !,"User successfully deleted!",! e d @@ -53,7 +53,7 @@ ; fetch a user - s ok=$$fetch^UserRoutines(2,.data) + s ok=$$fetch^User(2,.data) i ok=1 d . w !,"User successfully fetched!",! . w "username: ",data("username"),! @@ -64,7 +64,7 @@ ; drop database - s ok=$$drop^DatabaseRoutines() + s ok=$$drop^Database() i ok=1 d . w !,"Database successfully dropped!",! e d diff --git a/04-databases/basic-crud/DatabaseRoutines.m b/04-databases/basic-sql-crud/routines/Database.m similarity index 100% rename from 04-databases/basic-crud/DatabaseRoutines.m rename to 04-databases/basic-sql-crud/routines/Database.m diff --git a/04-databases/basic-crud/UserRoutines.m b/04-databases/basic-sql-crud/routines/User.m similarity index 100% rename from 04-databases/basic-crud/UserRoutines.m rename to 04-databases/basic-sql-crud/routines/User.m diff --git a/README.md b/README.md index e29957b..9a504fe 100644 --- a/README.md +++ b/README.md @@ -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)) 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! @@ -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: -- [`DatabaseRoutines.m`](https://github.com/programarivm/mumps-examples/blob/master/04-databases/basic-crud/DatabaseRoutines.m) -- [`UserRoutines.m`](https://github.com/programarivm/mumps-examples/blob/master/04-databases/basic-crud/UserRoutines.m) +- [`Database.m`](https://github.com/programarivm/mumps-examples/blob/master/04-databases/basic-sql-crud/routines/Database.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: slug: lorem-ipsum @@ -253,10 +253,10 @@ 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) -- [`DatabaseRoutines.m`](https://github.com/programarivm/mumps-examples/blob/master/04-databases/basic-blog/DatabaseRoutines.m) -- [`PostRoutines.m`](https://github.com/programarivm/mumps-examples/blob/master/04-databases/basic-blog/PostRoutines.m) -- [`UserRoutines.m`](https://github.com/programarivm/mumps-examples/blob/master/04-databases/basic-blog/UserRoutines.m) +- [`Comment.m`](https://github.com/programarivm/mumps-examples/blob/master/04-databases/basic-sql-blog/routines/Comment.m) +- [`Database.m`](https://github.com/programarivm/mumps-examples/blob/master/04-databases/basic-sql-blog/routines/Database.m) +- [`Post.m`](https://github.com/programarivm/mumps-examples/blob/master/04-databases/basic-sql-blog/routines/Post.m) +- [`User.m`](https://github.com/programarivm/mumps-examples/blob/master/04-databases/basic-sql-blog/routines/User.m) ---