Skip to content

Commit 5945534

Browse files
bump version and update Readme
1 parent 691771c commit 5945534

2 files changed

Lines changed: 56 additions & 2 deletions

File tree

README.md

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
![Seneca](http://senecajs.org/files/assets/seneca-logo.png)
2+
> A [Seneca.js][] data storage plugin
3+
14
seneca-postgresql-store
25
=======================
36

4-
[![Build Status](https://travis-ci.org/nherment/seneca-postgresql-store.svg)](https://travis-ci.org/nherment/seneca-postgresql-store)
7+
[![Build Status](https://travis-ci.org/marianr/seneca-postgresql-store.svg)](https://travis-ci.org/marianr/seneca-postgresql-store)
58

69
seneca-postgresql-store is a [PostgreSQL][postgresqlorg] database plugin for the [Seneca][seneca] MVP toolkit. The plugin is using the
710
[node-postgres][nodepg] driver.
@@ -35,6 +38,38 @@ Usage:
3538
[seneca]: http://senecajs.org/
3639
[nodepg]: https://github.com/brianc/node-postgres
3740

41+
## Usage
42+
You don't use this module directly. It provides an underlying data storage engine for the Seneca entity API:
43+
44+
```js
45+
var entity = seneca.make$('typename')
46+
entity.someproperty = "something"
47+
entity.anotherproperty = 100
48+
49+
entity.save$(function (err, entity) { ... })
50+
entity.load$({id: ...}, function (err, entity) { ... })
51+
entity.list$({property: ...}, function (err, entity) { ... })
52+
entity.remove$({id: ...}, function (err, entity) { ... })
53+
```
54+
55+
### Query Support
56+
The standard Seneca query format is supported:
57+
58+
- `.list$({f1:v1, f2:v2, ...})` implies pseudo-query `f1==v1 AND f2==v2, ...`.
59+
60+
- `.list$({f1:v1, ...}, {sort$:{field1:1}})` means sort by f1, ascending.
61+
62+
- `.list$({f1:v1, ...}, {sort$:{field1:-1}})` means sort by f1, descending.
63+
64+
- `.list$({f1:v1, ...}, {limit$:10})` means only return 10 results.
65+
66+
- `.list$({f1:v1, ...}, {skip$:5})` means skip the first 5.
67+
68+
- `.list$({f1:v1,...}, {fields$:['fd1','f2']})` means only return the listed fields.
69+
70+
Note: you can use `sort$`, `limit$`, `skip$` and `fields$` together.
71+
72+
3873
## Limits
3974

4075
By default queries are limited to 20 values. This can be bypassed by passing the `nolimit` option, which if set to true will not limit any queries.
@@ -44,3 +79,22 @@ By default queries are limited to 20 values. This can be bypassed by passing the
4479
To filter the fields returned from the `list` operation, pass a `fields$` array of column names to return. If no `fields$` are passed, all fields are returned (i.e. `select *` is used). e.g.
4580

4681
query.fields$ = ['id', 'name']
82+
83+
84+
### Native Driver
85+
As with all seneca stores, you can access the native driver, in this case, the `pg`
86+
`connection` object using `entity.native$(function (err, connectionPool, release) {...})`.
87+
Please make sure that you release the connection after using it.
88+
89+
```
90+
entity.native$( function (err, client, releaseConnection){
91+
// ... you can use client
92+
// ... then release connection
93+
releaseConnection()
94+
} )
95+
```
96+
97+
98+
## Contributing
99+
We encourage participation. If you feel you can help in any way, be it with
100+
examples, extra testing, or new features please get in touch.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "seneca-postgresql-store",
3-
"version": "0.7.0",
3+
"version": "0.8.0",
44
"description": "Seneca data store plugin for PostgreSQL",
55
"main": "lib/postgresql-store.js",
66
"author": "Marian Radulescu",

0 commit comments

Comments
 (0)