You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
seneca-postgresql-store is a [PostgreSQL][postgresqlorg] database plugin for the [Seneca][seneca] MVP toolkit. The plugin is using the
7
10
[node-postgres][nodepg] driver.
@@ -35,6 +38,38 @@ Usage:
35
38
[seneca]: http://senecajs.org/
36
39
[nodepg]: https://github.com/brianc/node-postgres
37
40
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
+
38
73
## Limits
39
74
40
75
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
44
79
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.
45
80
46
81
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.
0 commit comments