Skip to content

Commit 02b1e34

Browse files
committed
aligned documentation to double-done
1 parent 61a6a15 commit 02b1e34

File tree

4 files changed

+63
-37
lines changed

4 files changed

+63
-37
lines changed

README.md

+17-17
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# node-postgres-orm
1+
## node-postgres-orm
22

33
[![Build Status](https://travis-ci.org/iccicci/node-postgres-orm.png)](https://travis-ci.org/iccicci/node-postgres-orm)
44
[![Code Climate](https://codeclimate.com/github/iccicci/node-postgres-orm/badges/gpa.svg)](https://codeclimate.com/github/iccicci/node-postgres-orm)
@@ -18,21 +18,21 @@ Applying changes to database after releasing a new version of application is oft
1818
during development stage, often results in a complex sequence of backward and forward steps through migrations; this process is complicated more and more especially when
1919
working in team with concurrent changes to the models (or database schema). This package tries to solve these problems all in once.
2020

21-
# Table of Contents
21+
## Table of Contents
2222

2323
* [node-postgres-orm](#node-postgres-orm)
2424
* [Installation](#installation)
2525
* [Error reporting](#error-reporting])
2626
* [Usage error reporting](#usage-error-reporting)
2727
* [Data error reporting](#data-error-reporting)
2828
* [Quick Start Example](#quick-start-example)
29+
* [Requirements](#requirements)
30+
* [Testing](#testing)
2931
* [Bugs](#bugs)
3032
* [Documentation](#documentation)
3133
* [Changelog](#changelog)
32-
* [Requirements](#requirements)
33-
* [Testing](#testing)
3434

35-
# Installation
35+
## Installation
3636

3737
With [npm](https://www.npmjs.com/package/pgo):
3838
```sh
@@ -41,15 +41,15 @@ $ npm install --save pgo
4141

4242
Back to: [top](#) - [ToC](#table-of-contents)
4343

44-
# Error reporting
44+
## Error reporting
4545

46-
## Usage error reporting
46+
### Usage error reporting
4747

4848
__Pgo__ _functions_ and _methods_ have syncornous usage error reporting. Exceptions are thrown in case of wrong
4949
parameters number or types. Anyway it should not be required to call __pgo__ _functions_ in a __try catch__ block,
5050
this kind of errors should be generated only at development time.
5151

52-
## Data error reporting
52+
### Data error reporting
5353

5454
All __pgo__ _methods_ and _function_ accessing data have asyncronous error reporting to check data integrity or
5555
consistency errors, database connection errors, etc...
@@ -58,7 +58,7 @@ __Pgo__ implements the [double done](https://www.npmjs.com/package/double-done)
5858

5959
Back to: [top](#) - [ToC](#table-of-contents)
6060

61-
# Quick Start Example
61+
## Quick Start Example
6262

6363
```javascript
6464
var Pgo = require('pgo');
@@ -88,7 +88,7 @@ db.connect(console.log, function() {
8888
});
8989
```
9090

91-
## Output example
91+
### Output example
9292

9393
On db creation:
9494

@@ -132,12 +132,12 @@ Pgo: ALTER TABLE bars ALTER COLUMN baz TYPE varchar(20)
132132
Pgo: ALTER TABLE bars ALTER COLUMN baz DROP NOT NULL
133133
```
134134

135-
# Requirements
135+
## Requirements
136136

137137
* __Node.js 5.0__ or higher.
138138
* __PostgreSQL 9.3__ or higher.
139139

140-
# Testing
140+
## Testing
141141

142142
To test this package is strongly required the acces to a __PosgtreSQL__ database. The connection string should
143143
be specified in the _evironment variable_ __PGO_TEST_DB__.
@@ -153,13 +153,13 @@ __PostgreSQL__.
153153

154154
Back to: [top](#) - [ToC](#table-of-contents)
155155

156-
# Bugs
156+
## Bugs
157157

158158
Do not hesitate to report any bug or inconsistency [@github](https://github.com/iccicci/node-postgres-orm/issues).
159159

160-
## Known bugs
160+
### Known bugs
161161

162-
### Inheritance in clone
162+
#### Inheritance in clone
163163

164164
Model inheritance is not respected in __models__ of _cloned_ __Pgo__.
165165

@@ -184,7 +184,7 @@ db1.connect(console.log, function() {
184184

185185
Back to: [top](#) - [ToC](#table-of-contents)
186186

187-
# Documentation
187+
## Documentation
188188

189189
Documentation can be found at
190190
[documentation index](https://github.com/iccicci/node-postgres-orm/blob/master/doc/Home.md).
@@ -194,7 +194,7 @@ or not working as described.
194194

195195
Back to: [top](#) - [ToC](#table-of-contents)
196196

197-
# Changelog
197+
## Changelog
198198

199199
* 2017-??-?? - v0.2.0
200200
* Added [double done](https://www.npmjs.com/package/double-done)

doc/Pgo.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ The object which defines _model_ or _table_ options.
191191

192192
## load
193193
```javascript
194-
Pgo.load.<model_name>(where [, order], callback)
194+
Pgo.load.<model_name>(where [, order], done [, doneOk])
195195
```
196196

197197
Reads data from database with a standard __SQL query__ and makes it a set of __pgo.record__(s).
@@ -204,7 +204,8 @@ Please refer to [Accessing data](AccessingData.md) for details.
204204
The _Array_ which defines the __ORDER BY__ field list. It can be simply omitted.
205205
Please refer to [Accessing data](AccessingData.md) for details.
206206

207-
#### callback(err, res)
207+
#### done(err [, res])
208+
#### doneOk(res)
208209
The _callback_ function __pgo__ will call after data is loaded.
209210

210211
* __err__: the error description, __null__ if data loaded without errors.
@@ -217,6 +218,10 @@ new Pgo.models.<model_name>([tx])
217218

218219
Creates a __new pgo.record__ to be saved later in database.
219220

221+
#### tx
222+
223+
The transaction within the __Pgo.record__ must be saved (_inserted_).
224+
220225
#### return value
221226
The newly created __pgo__ [Record](Record.md).
222227
[comment]: <> (doc end)

doc/Record.md

+31
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,37 @@ The _callback_ function __pgo__ will call after __record__ is saved.
5656

5757
* __err__: the error description, __null__ if record was saved without errors.
5858

59+
# Accessors
60+
61+
## <FKEY_name>Load
62+
```javascript
63+
Record.<FKEY_name>Load(done [, doneOk])
64+
```
65+
66+
Loads the __pgo.record__ referenced by the __foreing key__.
67+
68+
#### done(err [,res])
69+
#### doneOk(res)
70+
The _callback_ function __pgo__ will call after __record__ is saved.
71+
72+
* __err__: the error description, __null__ if data loaded without errors.
73+
* __res__: the __pgo.record__ referenced by one against te _accessor_ was called.
74+
75+
## <FKEY_name>Lock
76+
```javascript
77+
Record.<FKEY_name>Lock(done [, doneOk])
78+
```
79+
80+
If the __pgo.record__ was loaded or created within a __transaction__, loads and locks the __pgo.record__ referenced by
81+
the __foreing key__.
82+
83+
#### done(err [,res])
84+
#### doneOk(res)
85+
The _callback_ function __pgo__ will call after __record__ is saved.
86+
87+
* __err__: the error description, __null__ if data loaded without errors.
88+
* __res__: the __pgo.record__ referenced by one against te _accessor_ was called.
89+
5990
# Hooks
6091

6192
## postDelete

doc/Transaction.md

+8-18
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,26 @@ actions on _database_ in the current _transaction_.
2727

2828
## commit
2929
```javascript
30-
Pgo.commit(callback)
30+
Transaction.commit(done [, doneOk])
3131
```
3232

3333
Issues the __COMMIT__ command and closes the __pg__ client.
3434

35-
#### callback(err)
35+
#### done(err)
36+
#### doneOk()
3637
The _callback_ function __pgo__ will call after the __COMMIT__ command is issued to database.
3738

3839
* __err__: the error description, __null__ if no errors occurred.
3940

4041
## client
4142
```javascript
42-
Pgo.rollback(callback)
43+
Transaction.rollback(done [, doneOk])
4344
```
4445

4546
Issues the __ROLLBACK__ command and closes the __pg__ client.
4647

47-
#### callback(err)
48+
#### done(err)
49+
#### doneOk()
4850
The _callback_ function __pgo__ will call after the __ROLLBACK__ command is issued to database.
4951

5052
* __err__: the error description, __null__ if no errors occurred.
@@ -54,26 +56,14 @@ The _callback_ function __pgo__ will call after the __ROLLBACK__ command is issu
5456

5557
## load
5658
```javascript
57-
Pgo.load.<model_name>(where, order, callback)
58-
```
59-
60-
or
61-
62-
```javascript
63-
Pgo.load.<model_name>(where, callback)
59+
Transaction.load.<model_name>(where, [order,] done [, doneOk])
6460
```
6561

6662
It works as __Pgo.load__ but it works within _transaction_.
6763

6864
## lock
6965
```javascript
70-
Pgo.lock.<model_name>(where, order, callback)
71-
```
72-
73-
or
74-
75-
```javascript
76-
Pgo.lock.<model_name>(where, callback)
66+
Transaction.lock.<model_name>(where, [order,] done [, doneOk])
7767
```
7868

7969
It works as __Transaction.load__ but it __locks__ the records untill the _transaction_ is

0 commit comments

Comments
 (0)