-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathexample.js
More file actions
44 lines (35 loc) · 1.02 KB
/
Copy pathexample.js
File metadata and controls
44 lines (35 loc) · 1.02 KB
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
// Copyright IBM Corp. 2016. All Rights Reserved.
// Node module: loopback-connector-db2
// This file is licensed under the Artistic License 2.0.
// License text available at https://opensource.org/licenses/Artistic-2.0
'use strict';
const DataSource = require('loopback-datasource-juggler').DataSource;
const DB2 = require('../'); // loopback-connector-db2
const config = {
username: process.env.DB2_USERNAME,
password: process.env.DB2_PASSWORD,
hostname: process.env.DB2_HOSTNAME,
port: 50000,
database: 'SQLDB',
};
const db = new DataSource(DB2, config);
const User = db.define('User', {name: {type: String}, email: {type: String},
});
db.autoupdate('User', function(err) {
if (err) {
console.log(err);
return;
}
User.create({
name: 'Tony',
email: 'tony@t.com',
}, function(err, user) {
console.log(err, user);
});
User.find({where: {name: 'Tony'}}, function(err, users) {
console.log(err, users);
});
User.destroyAll(function() {
console.log('example compconste');
});
});