@@ -44,8 +44,9 @@ const app = express();
4444const path = require ( 'path' ) ;
4545
4646const password = process . env . ATP_PWD ;
47+ console . log ( "atp password:" + password ) ;
4748
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/' } ) ;
4950
5051async function init ( ) {
5152 try {
@@ -59,25 +60,53 @@ async function init() {
5960 console . log ( 'Connection pool started succesfully.' ) ;
6061 } catch ( err ) {
6162 console . error ( 'init() error: ' + err . message ) ;
63+ console . log ( 'priceadmin/atp_pwd' ) ;
6264 }
6365}
6466
6567app . 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 ) ;
6971 } ) ;
7072} ) ;
7173
72- async function getDate ( ) {
74+ async function getSodaDoc ( ) {
7375 let connection ;
7476 try {
7577 // Get a connection from the default pool
7678 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 ;
81110 } catch ( err ) {
82111 console . error ( err ) ;
83112 } finally {
0 commit comments