Skip to content

Commit 41d9e3c

Browse files
committed
Deploying to gh-pages from @ 5b63863 🚀
1 parent 5b63863 commit 41d9e3c

10 files changed

+2640
-0
lines changed

pages/en/lb3/readmes/loopback-connector-couchdb2.md

Lines changed: 473 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
# loopback-connector-dashdb
2+
3+
[IBM® DashDB®]() is the database of choice for robust, enterprise-wide solutions handling high-volume workloads.
4+
It is optimized to deliver industry-leading performance while lowering costs. The `loopback-connector-dashdb`
5+
module is the LoopBack connector for dashDB.
6+
7+
The LoopBack DashDB connector supports:
8+
9+
- All [CRUD operations](http://loopback.io/doc/en/lb3/Creating-updating-and-deleting-data.html).
10+
- [Queries](http://loopback.io/doc/en/lb3/Querying-data.html) with fields, limit, order, skip and where filters.
11+
- All supported DASHDB LUW versions as well as dashDB. Note for dashDB set supportDashDB in the loopback datasource definition. Column organized tables are not supported.
12+
13+
## Installation
14+
15+
Enter the following in the top-level directory of your LoopBack application:
16+
17+
```
18+
$ npm install loopback-connector-dashdb --save
19+
```
20+
21+
The `--save` option adds the dependency to the application's `package.json` file.
22+
23+
## Configuration
24+
25+
Use the [data source generator](http://loopback.io/doc/en/lb3/Data-source-generator.html) (`lb datasource`) to add the DASHDB data source to your application.
26+
The entry in the application's `server/datasources.json` will look something like this:
27+
28+
```
29+
"mydb": {
30+
"name": "mydb",
31+
"connector": "dashdb"
32+
}
33+
```
34+
35+
Edit `server/datasources.json` to add other supported properties as required:
36+
37+
```
38+
"mydb": {
39+
"name": "mydb",
40+
"connector": "dashdb",
41+
"username": <username>,
42+
"password": <password>,
43+
"database": <database name>,
44+
"hostname": <dashdb server hostname>,
45+
"port": <port number>
46+
}
47+
```
48+
49+
The following table describes the connector properties.
50+
51+
Property | Type | Description
52+
---------------| --------| --------
53+
database | String | Database name
54+
schema | String | Specifies the default schema name that is used to qualify unqualified database objects in dynamically prepared SQL statements. The value of this property sets the value in the CURRENT SCHEMA special register on the database server. The schema name is case-sensitive, and must be specified in uppercase characters
55+
username | String | DASHDB Username
56+
password | String | DASHDB password associated with the username above
57+
hostname | String | DASHDB server hostname or IP address
58+
port | String | DASHDB server TCP port number
59+
useLimitOffset | Boolean | LIMIT and OFFSET must be configured on the DASHDB server before use (compatibility mode)
60+
supportDashDB | Boolean | Create ROW ORGANIZED tables to support dashDB.
61+
minPoolSize | Number | Set the minimum size of the connection pool |
62+
maxPoolSize | Number | Set the maximum size of the connection pool |
63+
64+
65+
Alternatively, you can create and configure the data source in JavaScript code.
66+
For example:
67+
68+
```
69+
var DataSource = require('loopback-datasource-juggler').DataSource;
70+
var DASHDB = require('loopback-connector-dashdb');
71+
72+
var config = {
73+
username: process.env.DASHDB_USERNAME,
74+
password: process.env.DASHDB_PASSWORD,
75+
hostname: process.env.DASHDB_HOSTNAME,
76+
port: 50000,
77+
database: 'SQLDB',
78+
};
79+
80+
var db = new DataSource(DASHDB, config);
81+
82+
var User = db.define('User', {
83+
name: { type: String },
84+
email: { type: String },
85+
});
86+
87+
db.autoupdate('User', function(err) {
88+
if (err) {
89+
console.log(err);
90+
return;
91+
}
92+
93+
User.create({
94+
name: 'Tony',
95+
email: 'tony@t.com',
96+
}, function(err, user) {
97+
console.log(err, user);
98+
});
99+
100+
User.find({ where: { name: 'Tony' }}, function(err, users) {
101+
console.log(err, users);
102+
});
103+
104+
User.destroyAll(function() {
105+
console.log('example complete');
106+
});
107+
});
108+
```
109+
110+
## Operators
111+
112+
Here is a list of operators supported by the connector:
113+
114+
- `regexp` operator
115+
```js
116+
Employee.find({where: {taskCode: {regexp: /tsk/i}}}, function(err, result) {
117+
if (err) throw err;
118+
console.log('Found instance with regexp: ' + JSON.stringify(result));
119+
});
120+
```
121+
122+
- `like` operator
123+
```js
124+
Employee.find({where: {taskCode: {like: 'TSK%'}}}, function(err, result) {
125+
if (err) throw err;
126+
console.log('Found instance with like: ' + JSON.stringify(result));
127+
});
128+
```
129+
130+
- `nlike` operator
131+
```js
132+
Employee.find({where: {taskCode: {nlike: 'TSK%'}}}, function(err, result) {
133+
if (err) throw err;
134+
console.log('Found instance with like: ' + JSON.stringify(result));
135+
});
136+
```
137+
138+
## Running tests
139+
140+
### Own instance
141+
142+
If you have a local or remote DashDB instance and would like to use that to run the test suite, use the following command:
143+
- Linux
144+
```bash
145+
DASHDB_HOSTNAME=<HOST> DASHDB_PORTNUM=<PORT> DASHDB_USERNAME=<USER> DASHDB_PASSWORD=<PASSWORD> DASHDB_DATABASE=<DATABASE> DASHDB_SCHEMA=<SCHEMA> CI=true npm test
146+
```
147+
- Windows
148+
```bash
149+
SET DASHDB_HOSTNAME=<HOST>
150+
SET DASHDB_PORTNUM=<PORT>
151+
SET DASHDB_USERNAME=<USER>
152+
SET DASHDB_PASSWORD=<PASSWORD>
153+
SET DASHDB_DATABASE=<DATABASE>
154+
SET DASHDB_SCHEMA=<SCHEMA>
155+
SET CI=true
156+
npm test
157+
```
158+
159+
The value for `DASHDB_SCHEMA` must be of the pattern `SCHEMA{build number}_{build name}_{platform}_{node version}`.
160+
For example : **SCHEMA1_DASHDB_DARWIN_10**.
161+
162+
Alternatively, let `DASHDB_SCHEMA` be computed for you by setting these values instead:
163+
164+
```bash
165+
export PACKAGE_NAME=loopback-connector-dashdb
166+
export BUILD_NUMBER={build number} For example: 1
167+
export nodeVersion={node version} For example: 10
168+
```
169+
170+
This will create a schema with the name: **SCHEMA1_DASHDB_DARWIN_10**
171+
172+
This pattern of the schema name is important for database **cleanup** and **seeding** purposes.
173+
174+
### Docker
175+
- DashDB has a docker image which could be signed up for a trial version and be used for testing. For more information, please visit: [DashDB Docker](https://hub.docker.com/r/dashdb/local/)
176+
- Once the instance is ready, please follow the above information on how to run tests using your [own instance](https://github.com/loopbackio/loopback-connector-dashdb/tree/master#own-instance)
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
# loopback-connector-db2
2+
3+
[IBM® DB2®](http://www.ibm.com/analytics/us/en/technology/db2/) is the database of choice for robust, enterprise-wide solutions handling high-volume workloads.
4+
It is optimized to deliver industry-leading performance while lowering costs. The `loopback-connector-db2` module is the LoopBack connector for DB2.
5+
6+
The LoopBack DB2 connector supports:
7+
8+
- All [create, retrieve, update, and delete operations](http://loopback.io/doc/en/lb2/Creating-updating-and-deleting-data.html).
9+
- [Queries](http://loopback.io/doc/en/lb2/Querying-data.html) with fields, limit, order, skip and where filters.
10+
- All supported DB2 LUW versions.
11+
12+
## Installation
13+
14+
Enter the following in the top-level directory of your LoopBack application:
15+
16+
```
17+
$ npm install loopback-connector-db2 --save
18+
```
19+
20+
The `--save` option adds the dependency to the application's `package.json` file.
21+
22+
## Configuration
23+
24+
Use the [data source generator](http://loopback.io/doc/en/lb3/Data-source-generator.html) to add the DB2 data source to your application.
25+
The entry in the application's `server/datasources.json` will look something like this:
26+
27+
```js
28+
"mydb": {
29+
"name": "mydb",
30+
"connector": "db2"
31+
}
32+
```
33+
34+
Edit `server/datasources.json` to add other supported properties as required:
35+
36+
```js
37+
"mydb": {
38+
"name": "mydb",
39+
"connector": "db2",
40+
"username": <username>,
41+
"password": <password>,
42+
"database": <database name>,
43+
"hostname": <db2 server hostname>,
44+
"port": <port number>
45+
}
46+
```
47+
48+
The following table describes the connector properties.
49+
50+
Property&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | Type&nbsp;&nbsp; | Description
51+
---------------| --------| --------
52+
database | String | Database name
53+
schema | String | Specifies the default schema name that is used to qualify unqualified database objects in dynamically prepared SQL statements. The value of this property sets the value in the CURRENT SCHEMA special register on the database server. The schema name is case-sensitive, and must be specified in uppercase characters
54+
username | String | DB2 Username
55+
password | String | DB2 password associated with the username above
56+
hostname | String | DB2 server hostname or IP address
57+
port | String | DB2 server TCP port number
58+
useLimitOffset | Boolean | LIMIT and OFFSET must be configured on the DB2 server before use (compatibility mode)
59+
supportDashDB | Boolean | Create ROW ORGANIZED tables to support dashDB.
60+
dsn | String | DSN string; can be used instead of the username, password, database, hostname and port properties
61+
maxPoolSize | Number | Maximum number of connections in the connection pool
62+
63+
64+
Alternatively, you can create and configure the data source in JavaScript code.
65+
For example:
66+
67+
```js
68+
var DataSource = require('loopback-datasource-juggler').DataSource;
69+
var DB2 = require('loopback-connector-db2');
70+
71+
var config = {
72+
username: process.env.DB2_USERNAME,
73+
password: process.env.DB2_PASSWORD,
74+
hostname: process.env.DB2_HOSTNAME,
75+
port: 50000,
76+
database: 'SQLDB',
77+
};
78+
79+
var db = new DataSource(DB2, config);
80+
81+
var User = db.define('User', {
82+
name: { type: String },
83+
email: { type: String },
84+
});
85+
86+
db.autoupdate('User', function(err) {
87+
if (err) {
88+
console.log(err);
89+
return;
90+
}
91+
92+
User.create({
93+
name: 'Tony',
94+
email: 'tony@t.com',
95+
}, function(err, user) {
96+
console.log(err, user);
97+
});
98+
99+
User.find({ where: { name: 'Tony' }}, function(err, users) {
100+
console.log(err, users);
101+
});
102+
103+
User.destroyAll(function() {
104+
console.log('example complete');
105+
});
106+
});
107+
```
108+
109+
## Running tests
110+
111+
### Own instance
112+
113+
If you have a local or remote DB2 instance and would like to use that to run the test suite, use the following command:
114+
- Linux
115+
```bash
116+
DB2_HOSTNAME=<HOST> DB2_PORTNUM=<PORT> DB2_USERNAME=<USER> DB2_PASSWORD=<PASSWORD> DB2_DATABASE=<DATABASE> DB2_SCHEMA=<SCHEMA> CI=true npm test
117+
```
118+
- Windows
119+
```bash
120+
SET DB2_HOSTNAME=<HOST>
121+
SET DB2_PORTNUM=<PORT>
122+
SET DB2_USERNAME=<USER>
123+
SET DB2_PASSWORD=<PASSWORD>
124+
SET DB2_DATABASE=<DATABASE>
125+
SET DB2_SCHEMA=<SCHEMA>
126+
SET CI=true
127+
npm test
128+
```
129+
130+
#### How to get a local DB2 instance:
131+
132+
- Go to [IBM DB2 trials](http://www.ibm.com/analytics/us/en/technology/db2/db2-trials.html) page.
133+
- Register for an account.
134+
- Download either IBM DB2 or IBM DB2 Express-C.
135+
- For documentation or more information about the installation or setup, see http://www.ibm.com/support/knowledgecenter/SSEPGG_11.1.0/com.ibm.db2.luw.kc.doc/welcome.html
136+
137+
#### IBM DB2 Express-C scenario on Windows:
138+
- Run the setup file.
139+
- Set user information for the DB2 Administration server.
140+
- Write down the user information and the password that you create. User name is `db2admin` by default but it could be modified.
141+
- Configure DB2 instance and write down the port number. It is 50000 by default.
142+
- Once setup is done, Start the `default DB2 and Database Client Interface Selection Wizard`, and proceed with the configuration.
143+
- Ensure that the DB2 Data server runtime client is started. The default name is `DB2COPY1`.
144+
- Let's assume your database name is `sample`, and schema name is `STRONGLOOP`.
145+
- In Windows, start the DB2 Command window-Administrator (In Mac or Linux, use terminal with proper privileges).
146+
- Make sure that you are in this path `...\IBM\SQLLIB\BIN` (In mac, it should be ` /Users/<userid>/sqllib\bin`), and type the following commands:
147+
148+
```
149+
>set db2instance=server1
150+
151+
>db2 connect to sample
152+
153+
>db2 set schema to STRONGLOOP
154+
```
155+
156+
### Docker
157+
If you do not have a local DB2 instance, you can also run the test suite with very minimal requirements.
158+
- Assuming you have [Docker](https://docs.docker.com/engine/installation/) installed, run the following script which would spawn a DB2 instance on your local:
159+
```bash
160+
source setup.sh <HOST> <PORT> <PASSWORD> <DATABASE>
161+
```
162+
where `<HOST>`, `<PORT>`, `<PASSWORD>` and `<DATABASE>` are optional parameters. By default, the user is `db2inst1`.
163+
- Run the test:
164+
```bash
165+
npm test
166+
```

0 commit comments

Comments
 (0)