-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
67 lines (57 loc) · 1.78 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/**
* change database connection parameters in /node_modules/node-oracledb-wrapper/index.js under 'connect' function.
*/
//require node-oracledb-wrapper
var db = require('node-oracledb-wrapper');
//insert example
var dataToInsert = {
COUNTRY_NAME:'Zimbabum',
ISO_ALPHA2:'ZW',
ISO_ALPHA3:'ZWE',
ISO_NUMERIC:'720',
CURRENCY_CODE:'ZWD',
CURRENCY_NAME:'Dollar',
CURRRENCY_SYMBOL:'Z$',
FLAG:'ZW.png'
}
db.insert(dataToInsert).into('db_main','country_master').exec(function(newcountry){
console.log(newcountry);
res.jsonp(newcountry);
});
//fetch example
db.fetch().from('db_main','country_master').order('country_id','DESC').exec(function(responce){
console.log(responce);
res.jsonp(responce);
});
//fetch with where clause example
db.fetch().from('db_main','country_master').where({country_id:154}).exec(function(responce){
console.log(responce);
res.jsonp(responce);
});
//fetch with limit example ex:get 10 results
db.fetch().from('db_main','country_master').limit(10).exec(function(responce){
console.log(responce);
res.jsonp(responce);
});
//update example
var dataToUpdate = {
COUNTRY_NAME:'Zimhalka',
ISO_ALPHA2:'ZW',
ISO_ALPHA3:'ZWE',
ISO_NUMERIC:'720',
CURRENCY_CODE:'ZWD',
CURRENCY_NAME:'Dollar',
CURRRENCY_SYMBOL:'Z$',
FLAG:'ZW.png'
}
//update function
db.update(dataToUpdate).into('db_main','country_master').where({country_name:'Zimbhari'}).exec(function(resp){
res.jsonp(resp);
//{"rowsAffected": 1 }
});
//delete example
db.delete().from('db_main','country_master').where({country_name:'Zimhalka'}).exec(function(responce){
console.log(responce);
res.jsonp(responce);
//if deleted successfully responce will be {"rowsAffected": 1 } or {"rowsAffected": 0 } if failed
});