Skip to content

Commit 01efe14

Browse files
committed
Deploying to gh-pages from @ e87f042 🚀
1 parent e87f042 commit 01efe14

10 files changed

+1552
-0
lines changed
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# loopback-connector-db2z
2+
3+
[IBM® DB2® for z/OS®](https://www-01.ibm.com/software/data/db2/zos/family/) 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-db2z`
5+
module is the LoopBack connector for DB2z.
6+
7+
The LoopBack DB2z connector supports:
8+
9+
- All [create, retrieve, update, and delete operations](http://loopback.io/doc/en/lb2/Creating-updating-and-deleting-data.html).
10+
- [Queries](http://loopback.io/doc/en/lb2/Querying-data.html) with fields, limit, order, skip and where filters.
11+
12+
## Installation
13+
14+
Enter the following in the top-level directory of your LoopBack application:
15+
16+
```
17+
$ npm install loopback-connector-db2z --save
18+
```
19+
20+
The `--save` option adds the dependency to the application's `package.json` file.
21+
22+
This module is dependent on the `node-ibm_db` module which requires appropriate licenses be available as per instructions in its [README](https://github.com/ibmdb/node-ibm_db/blob/master/README.md). Once `loopback-connector-db2z` is installed please copy the required license file to the location described.
23+
24+
## Configuration
25+
26+
Use the [data source generator](http://loopback.io/doc/en/lb2/Data-source-generator.html) to add the DB2z data source to your application.
27+
The resulting entry in the application's `server/datasources.json` will look something like this:
28+
29+
```js
30+
"mydb": {
31+
"name": "mydb",
32+
"connector": "db2z"
33+
}
34+
```
35+
36+
Edit `server/datasources.json` to add other supported properties as required:
37+
38+
```js
39+
"mydb": {
40+
"name": "mydb",
41+
"connector": "db2z",
42+
"username": <username>,
43+
"password": <password>,
44+
"database": <database name>,
45+
"hostname": <db2z server hostname>,
46+
"port": <port number>
47+
}
48+
```
49+
50+
The following table describes the connector properties.
51+
52+
Property&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | Type&nbsp;&nbsp; | Description
53+
---------------| --------| --------
54+
database | String | Database name
55+
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
56+
username | String | DB2z Username
57+
password | String | DB2z password associated with the username above
58+
hostname | String | DB2z server hostname or IP address
59+
port | String | DB2z server TCP port number
60+
useLimitOffset | Boolean | LIMIT and OFFSET must be configured on the DB2z server before use (compatibility mode)
61+
supportDashDB | Boolean | Create ROW ORGANIZED tables to support dashDB.
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 DB2Z = require('loopback-connector-db2z');
70+
71+
var config = {
72+
username: process.env.DB2Z_USERNAME,
73+
password: process.env.DB2Z_PASSWORD,
74+
hostname: process.env.DB2Z_HOSTNAME,
75+
port: 50000,
76+
database: 'SQLDB',
77+
};
78+
79+
var db = new DataSource(DB2Z, 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+
```
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
# loopback-example-angular
2+
3+
**⚠️ This LoopBack 3 example project is no longer maintained. Please refer to [LoopBack 4 Examples](https://loopback.io/doc/en/lb4/Examples.html) instead. ⚠️**
4+
5+
```
6+
$ git clone https://github.com/strongloop/loopback-example-angular.git
7+
$ cd loopback-example-angular
8+
$ npm install
9+
$ node . # then browse to localhost:3000
10+
```
11+
12+
A simple todo list using AngularJS on the client-side and LoopBack on the
13+
server-side.
14+
15+
## Prerequisites
16+
17+
### Tutorials
18+
19+
- [Getting started with LoopBack](https://github.com/strongloop/loopback-getting-started)
20+
- [Tutorial series, step 1](https://github.com/strongloop/loopback-example#the-basics)
21+
22+
### Knowledge of
23+
24+
- [Angular](https://angularjs.org/)
25+
- [Angular Resource](https://docs.angularjs.org/api/ngResource/service/$resource)
26+
- [AngularUI Router](https://github.com/angular-ui/ui-router)
27+
- [Bootstrap](http://getbootstrap.com/)
28+
- [Bower](http://bower.io/)
29+
- [LoopBack](http://loopback.io/)
30+
- [LoopBack AngularJS SDK](http://loopback.io/doc/en/lb2/AngularJS-JavaScript-SDK.html)
31+
- [LoopBack models](http://loopback.io/doc/en/lb2/Defining-models.html)
32+
- [LoopBack middleware](http://loopback.io/doc/en/lb2/Defining-middleware.html)
33+
34+
## Procedure
35+
36+
### Create the application
37+
38+
#### Application information
39+
40+
- Name: `loopback-example-angular`
41+
- Directory to contain the project: `loopback-example-angular`
42+
43+
```
44+
$ slc loopback loopback-example-angular
45+
... # follow the prompts
46+
$ cd loopback-example-angular
47+
```
48+
49+
### Create the `Todo` model
50+
51+
#### Model information
52+
53+
- Name: `Todo`
54+
- Data source: `db (memory)`
55+
- Base class: `PersistedModel`
56+
- Expose over REST: `Yes`
57+
- Custom plural form: *Leave blank*
58+
- Properties:
59+
- `content`
60+
- String
61+
- Required
62+
63+
```
64+
$ slc loopback:model Todo
65+
... # follow the prompts
66+
```
67+
68+
### Configure the vendor directory
69+
70+
In the project root, create [`.bowerrc`](https://github.com/strongloop/loopback-example-angular/blob/master/.bowerrc).
71+
72+
>Bower installs packages in `bower_components` by default, but we reconfigure
73+
this to `client/vendor` to make [importing files into `index.html`](https://github.com/strongloop/loopback-example-angular/blob/master/client/index.html#L33-L37)
74+
more convenient.
75+
76+
### Install client-side dependencies
77+
78+
From the project root, run:
79+
80+
```
81+
$ bower install angular angular-resource angular-ui-router bootstrap
82+
```
83+
84+
### Create the home page
85+
86+
Create [`index.html`](https://github.com/strongloop/loopback-example-angular/blob/master/client/index.html) in the [`client`](https://github.com/strongloop/loopback-example-angular/blob/master/client) directory.
87+
88+
### Create the main stylesheet
89+
90+
Create a [`css` directory](https://github.com/strongloop/loopback-example-angular/blob/master/client/css) to store stylesheets.
91+
92+
```
93+
$ mkdir client/css
94+
```
95+
96+
In this directory, create [`styles.css`](https://github.com/strongloop/loopback-example-angular/blob/master/client/css/styles.css).
97+
98+
### Serve static assets from the `client` directory
99+
100+
Delete `/server/boot/root.js`.
101+
102+
Add static middleware to the [`files` section in `middleware.json`](https://github.com/strongloop/loopback-example-angular/blob/master/server/middleware.json#L23-L27)
103+
.
104+
105+
### Create `app.js`
106+
107+
Create a [`js` directory](https://github.com/strongloop/loopback-example-angular/blob/master/client/js) to hold scripts files.
108+
109+
```
110+
$ mkdir client/js
111+
```
112+
113+
In this directory, create [`app.js`](https://github.com/strongloop/loopback-example-angular/blob/master/client/js/app.js).
114+
115+
>Notice we declare [`lbServices`](https://github.com/strongloop/loopback-example-angular/blob/master/client/js/app.js#L3) as a dependency. We
116+
will generate this file using the `lb-ng` command in a later step.
117+
118+
### Create `todo.html`
119+
120+
Create a [`views`](https://github.com/strongloop/loopback-example-angular/blob/master/client/views) to store view templates.
121+
122+
```
123+
$ mkdir client/views
124+
```
125+
126+
In this directory, create [`todo.html`](https://github.com/strongloop/loopback-example-angular/blob/master/client/views/todo.html).
127+
128+
### Create `controllers.js`
129+
130+
Create a [`controllers`](https://github.com/strongloop/loopback-example-angular/blob/master/client/js/controllers) directory to store controller
131+
files.
132+
133+
```
134+
$ mkdir client/js/controllers
135+
```
136+
137+
In this directory, create [`todo.js`](https://github.com/strongloop/loopback-example-angular/blob/master/client/js/controllers/todo.js).
138+
139+
### Generate `lb-services.js`
140+
141+
Create a [`services` directory](https://github.com/strongloop/loopback-example-angular/blob/master/client/js/services) to store service files.
142+
143+
```
144+
$ mkdir client/js/services
145+
```
146+
147+
`lb-ng` is automatically installed along with the `slc` command-line tool (ie.
148+
when you ran `npm install -g strongloop`). `lb-ng` takes two arguments: the
149+
path to [`server.js`](https://github.com/strongloop/loopback-example-angular/blob/master/server/server.js) and the path
150+
to the [generated services file](https://github.com/strongloop/loopback-example-angular/blob/master/client/js/services/lb-services.js).
151+
[`lb-services.js`](https://github.com/strongloop/loopback-example-angular/blob/master/client/js/services/lb-services.js) is an Angular service
152+
used to interact with LoopBack models.
153+
154+
Create [`lb-services.js`](https://github.com/strongloop/loopback-example-angular/blob/master/client/js/services/lb-services.js) using the `lb-ng`
155+
command.
156+
157+
```
158+
$ lb-ng server/server.js client/js/services/lb-services.js
159+
```
160+
161+
### Run the application
162+
163+
From the project root, enter `node .` and browse to [`localhost:3000`](http://localhost:3000)
164+
to view the application.
165+
166+
---
167+
168+
[More LoopBack examples](https://loopback.io/doc/en/lb3/Tutorials-and-examples.html)

0 commit comments

Comments
 (0)