@@ -44,8 +44,9 @@ const app = express();
44
44
const path = require ( 'path' ) ;
45
45
46
46
const password = process . env . ATP_PWD ;
47
+ console . log ( "atp password:" + password ) ;
47
48
48
- oracledb . initOracleClient ( { libDir : '/instantclient_21_7 ' , configDir : '/instantclient_21_7 /network/admin/' } ) ;
49
+ oracledb . initOracleClient ( { libDir : '/instantclient_23_3 ' , configDir : '/instantclient_23_3 /network/admin/' } ) ;
49
50
50
51
async function init ( ) {
51
52
try {
@@ -59,25 +60,53 @@ async function init() {
59
60
console . log ( 'Connection pool started succesfully.' ) ;
60
61
} catch ( err ) {
61
62
console . error ( 'init() error: ' + err . message ) ;
63
+ console . log ( 'priceadmin/atp_pwd' ) ;
62
64
}
63
65
}
64
66
65
67
app . get ( '/' , ( req , res ) => {
66
- getDate ( ) . then ( ( date ) => {
67
- console . log ( date ) ;
68
- res . send ( date ) ;
68
+ getSodaDoc ( ) . then ( ( json ) => {
69
+ console . log ( json ) ;
70
+ res . send ( json ) ;
69
71
} ) ;
70
72
} ) ;
71
73
72
- async function getDate ( ) {
74
+ async function getSodaDoc ( ) {
73
75
let connection ;
74
76
try {
75
77
// Get a connection from the default pool
76
78
connection = await oracledb . getConnection ( ) ;
77
- const sql = `SELECT SYSDATE FROM DUAL` ;
78
- const result = await connection . execute ( sql ) ;
79
- const date = result . rows [ 0 ] ;
80
- return date ;
79
+ const soda = connection . getSodaDatabase ( ) ;
80
+ var collection = await soda . createCollection ( "hotel_reservations" ) ;
81
+ collection = await soda . openCollection ( "hotel_reservations" ) ;
82
+ const json = {
83
+ "reservation_id" : "2" ,
84
+ "hotel_id" : "123" ,
85
+ "room_id" : "315" ,
86
+ "checkin_date" : "2023-06-15" ,
87
+ "checkout_date" : "2023-06-17" ,
88
+ "num_adults" : 1 ,
89
+ "num_children" : 0 ,
90
+ "guest_name" : {
91
+ "first_name" : "Ethan" ,
92
+ "last_name" : "Lee"
93
+ } ,
94
+ "guest_contact_info" : {
95
+
96
+ "phone" : "123-8106" ,
97
+ "address" : {
98
+ "city" : "Madrid" ,
99
+ "country" : "Spain"
100
+ }
101
+ } ,
102
+ "total_cost" : 350.00 ,
103
+ "payment_status" : "paid"
104
+ }
105
+ var document = await collection . insertOneAndGet ( json ) ;
106
+ const key = document . key ;
107
+ document = await collection . find ( ) . key ( key ) . getOne ( ) ;
108
+ const content = await document . getContent ( ) ;
109
+ return content ;
81
110
} catch ( err ) {
82
111
console . error ( err ) ;
83
112
} finally {
0 commit comments