Skip to content

Commit 60a2ce2

Browse files
authored
Update README.md
1 parent 2b16164 commit 60a2ce2

File tree

1 file changed

+21
-66
lines changed

1 file changed

+21
-66
lines changed

README.md

Lines changed: 21 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
[![wercker status](https://app.wercker.com/status/74461495df913d3524f2a11c9db4cd9b/s/master "wercker status")](https://app.wercker.com/project/bykey/74461495df913d3524f2a11c9db4cd9b)
2-
[![Code Climate](https://codeclimate.com/github/node-modli/modli-postgres/badges/gpa.svg)](https://codeclimate.com/github/node-modli/modli-postgres)
3-
[![Test Coverage](https://codeclimate.com/github/node-modli/modli-postgres/badges/coverage.svg)](https://codeclimate.com/github/node-modli/modli-postgres/coverage)
4-
51
# Modli - PostgreSQL Adapter
62

73
This module provides adapter for the [PostgreSQL](http://www.postgresql.org/)
@@ -19,20 +15,20 @@ When defining a property which will utilize the adapter it is required that a
1915
`tableName` be supplied:
2016

2117
```javascript
22-
import { model, adapter, Joi, use } from 'modli';
23-
import postgres from 'modli-postgres';
18+
const { model, adapter, obey, use } = require('modli')
19+
const postgres from require('modli-postgres')
2420

2521
model.add({
2622
name: 'foo',
2723
version: 1,
2824
tableName: 'tblFoo'
29-
schema: {
30-
id: Joi.number().integer(),
31-
fname: Joi.string().min(3).max(30),
32-
lname: Joi.string().min(3).max(30),
33-
email: Joi.string().email().min(3).max(254).required()
34-
}
35-
});
25+
schema: obey.model({
26+
id: { type: 'number' },
27+
fname: { type: 'string', min: 3, max: 30 },
28+
lname: { type: 'string', min: 3, max: 30 },
29+
email: { type: 'email', min: 3, max: 254, required: true }
30+
})
31+
})
3632
```
3733

3834
Then add the adapter as per usual with the following config object structure:
@@ -43,18 +39,18 @@ adapter.add({
4339
source: postgres
4440
config: {
4541
host: {HOST_IP},
46-
username: {USERNAME},
42+
user: {USERNAME},
4743
password: {PASSWORD},
4844
database: {DATABASE}
4945
}
50-
});
46+
})
5147
```
5248

5349
You can then use the adapter with a model via:
5450

5551
```javascript
5652
// Use(MODEL, ADAPTER)
57-
const postgresTest = use('foo', 'postgresFoo');
53+
const postgresTest = use('foo', 'postgresFoo')
5854
```
5955

6056
## Methods
@@ -68,7 +64,7 @@ Allows for passing standard PostgreSQL queries:
6864
```javascript
6965
postgresTest.query('SELECT * FROM tblFoo')
7066
.then(/*...*/)
71-
.catch(/*...*/);
67+
.catch(/*...*/)
7268
```
7369

7470
### `createTable`
@@ -83,7 +79,7 @@ postgresTest.createTable({
8379
'email': [ 'varchar(255)' ]
8480
})
8581
.then(/*...*/)
86-
.catch(/*...*/);
82+
.catch(/*...*/)
8783
```
8884

8985
### `create`
@@ -97,7 +93,7 @@ postgresTest.create({
9793
email: 'jsmith@gmail.com'
9894
})
9995
.then(/*...*/)
100-
.catch(/*...*/);
96+
.catch(/*...*/)
10197
```
10298

10399
### `read`
@@ -107,7 +103,7 @@ Runs a `SELECT` with optional `WHERE`:
107103
```javascript
108104
postgresTest.read('fname=\'John\'')
109105
.then(/*...*/)
110-
.catch(/*...*/);
106+
.catch(/*...*/)
111107
```
112108

113109
### `update`
@@ -120,7 +116,7 @@ postgresTest.update('fname=\'John\'', {
120116
email: 'bsmith@gmail.com'
121117
})
122118
.then(/*...*/)
123-
.catch(/*...*/);
119+
.catch(/*...*/)
124120
```
125121

126122
### `delete`
@@ -130,7 +126,7 @@ Deletes record(s) based on query:
130126
```javascript
131127
postgresTest.delete('fname=\'Bob\'')
132128
.then(/*...*/)
133-
.catch(/*...*/);
129+
.catch(/*...*/)
134130
```
135131

136132
### `extend`
@@ -140,12 +136,12 @@ Extends the adapter to allow for custom methods:
140136
```javascript
141137
postgresTest.extend('myMethod', () => {
142138
/*...*/
143-
});
139+
})
144140
```
145141

146142
## Development
147143

148-
The PostgreSQL adapter requires the following enviroment variables to be set for
144+
The PostgreSQL adapter requires the following environment variables to be set for
149145
running the tests. These should be associated with the PostgreSQL instance running
150146
locally.
151147

@@ -159,51 +155,10 @@ MODLI_POSTGRES_DATABASE
159155
This repository includes a base container config for running locally which is
160156
located in the [/docker](/docker) directory.
161157

162-
## Makefile and Scripts
163-
164-
A `Makefile` is included for managing build and install tasks. The commands are
165-
then referenced in the `package.json` `scripts` if that is the preferred
166-
task method:
167-
168-
* `all` (default) will run all build tasks
169-
* `start` will run the main script
170-
* `clean` will remove the `/node_modules` directories
171-
* `build` will transpile ES2015 code in `/src` to `/build`
172-
* `test` will run all spec files in `/test/src`
173-
* `test-cover` will run code coverage on all tests
174-
* `lint` will lint all files in `/src`
175-
176-
## Testing
177-
178-
Running `make test` will run the full test suite. Since adapters require a data
179-
source if one is not configured the tests will fail. To counter this tests are
180-
able to be broken up.
181-
182-
**Test Inidividual File**
183-
184-
An individual spec can be run by specifying the `FILE`. This is convenient when
185-
working on an individual adapter.
186-
187-
```
188-
make test FILE=some.spec.js
189-
```
190-
191-
The `FILE` is relative to the `test/src/` directory.
192-
193-
**Deploys**
194-
195-
For deploying releases, the `deploy TAG={VERSION}` can be used where `VERSION` can be:
196-
197-
```
198-
<newversion> | major | minor | patch | premajor
199-
```
200-
201-
Both `make {COMMAND}` and `npm run {COMMAND}` work for any of the above commands.
202-
203158
## License
204159

205160
Modli-Postgres is licensed under the MIT license. Please see `LICENSE.txt` for full details.
206161

207162
## Credits
208163

209-
Modli-Postgres was designed and created at [TechnologyAdvice](http://www.technologyadvice.com).
164+
Modli-Postgres was designed and created at [TechnologyAdvice](http://www.technologyadvice.com).

0 commit comments

Comments
 (0)