Skip to content

Commit fae3b2c

Browse files
authored
Merge pull request #868 from oracle-devrel/atp-operator-nodejs-change
soda added
2 parents b779329 + fb0c4d0 commit fae3b2c

File tree

3 files changed

+42
-13
lines changed

3 files changed

+42
-13
lines changed

app-dev/oke/atp-operator-nodejs/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ WORKDIR /
44

55
RUN apt-get update && apt-get install -y libaio1
66

7-
ENV LD_LIBRARY_PATH=/instantclient_21_7
7+
ENV LD_LIBRARY_PATH=/instantclient_23_3
88

99
COPY ["package.json", "package-lock.json*", "./"]
1010

1111
RUN npm install
1212

1313
COPY . .
1414

15-
RUN unzip instantclient-basic-linux.x64-21.7.0.0.0dbru.zip
15+
RUN unzip instantclient-basic-linux.x64-23.3.0.0.0.zip
1616

17-
RUN rm -f instantclient-basic-linux.x64-21.7.0.0.0dbru.zip
17+
RUN rm -f instantclient-basic-linux.x64-23.3.0.0.0.zip
1818

1919
CMD [ "node", "server.js" ]

app-dev/oke/atp-operator-nodejs/nodejs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ spec:
2626
- containerPort: 3000
2727
volumeMounts:
2828
- name: secret-volume
29-
mountPath: /instantclient_21_7/network/admin
29+
mountPath: /instantclient_23_3/network/admin
3030
env:
3131
- name: ATP_PWD
3232
valueFrom:

app-dev/oke/atp-operator-nodejs/source/server.js

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ const app = express();
4444
const path = require('path');
4545

4646
const 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

5051
async 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

6567
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);
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+
"email": "[email protected]",
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

Comments
 (0)