mumps-demo/04-databases/basic-sql-crud/Main.m

72 lines
1.6 KiB
Mathematica
Raw Normal View History

; create users
2019-09-27 16:06:39 -04:00
s ok=$$set^User(1,"alice~password~alice-jones@no-reply.com~Alice Jones")
i ok=1 d
2019-09-27 06:30:58 -04:00
. w "User successfully created!",!
e d
2019-09-27 06:30:58 -04:00
. w "Whoops! The user could not be created.",!
2019-09-27 16:06:39 -04:00
s ok=$$set^User(2,"bob~password~bob-smith@no-reply.com~Bob Smith")
i ok=1 d
2019-09-27 06:30:58 -04:00
. w "User successfully created!",!
e d
2019-09-27 06:30:58 -04:00
. w "Whoops! The user could not be created.",!
; fetch a user
2019-09-27 16:06:39 -04:00
s ok=$$fetch^User(1,.data)
i ok=1 d
2019-09-27 06:30:58 -04:00
. w !,"User successfully fetched!",!
. w "username: ",data("username"),!
. w "email: ",data("email"),!
. w "fullname: ",data("fullname"),!
e d
2019-09-27 06:30:58 -04:00
. w "Whoops! The user could not be fetched.",!
; update a user
2019-09-27 16:06:39 -04:00
s ok=$$set^User(1,"amelia~password~amelia-roberts@no-reply.com~Amelia Roberts")
i ok=1 d
2019-09-27 06:30:58 -04:00
. w !,"User successfully updated!",!
e d
2019-09-27 06:30:58 -04:00
. w !,"Whoops! The user could not be updated.",!
; fetch a user
2019-09-27 16:06:39 -04:00
s ok=$$fetch^User(1,.data)
i ok=1 d
2019-09-27 06:30:58 -04:00
. w !,"User successfully fetched!",!
. w "username: ",data("username"),!
. w "email: ",data("email"),!
. w "fullname: ",data("fullname"),!
e d
2019-09-27 06:30:58 -04:00
. w "Whoops! The user could not be fetched.",!
; delete a user
2019-09-27 16:06:39 -04:00
s ok=$$remove^User(2)
i ok=1 d
2019-09-27 06:30:58 -04:00
. w !,"User successfully deleted!",!
e d
2019-09-27 06:30:58 -04:00
. w !,"Whoops! The user could not be deleted.",!
; fetch a user
2019-09-27 16:06:39 -04:00
s ok=$$fetch^User(2,.data)
i ok=1 d
2019-09-27 06:30:58 -04:00
. w !,"User successfully fetched!",!
. w "username: ",data("username"),!
. w "email: ",data("email"),!
. w "fullname: ",data("fullname"),!
e d
2019-09-27 06:30:58 -04:00
. w "Whoops! The user could not be fetched.",!
; drop database
2019-09-27 16:06:39 -04:00
s ok=$$drop^Database()
i ok=1 d
2019-09-27 06:30:58 -04:00
. w !,"Database successfully dropped!",!
e d
2019-09-27 06:30:58 -04:00
. w !,"Whoops! The database could not be dropped.",!