@@ -11,11 +11,11 @@ implement.
11
11
12
12
## Interfaces
13
13
14
- - [ Queryable] [ ] - a common interface implemented by connections, pools, and
15
- transactions.
16
- - [ Connection] [ ] - the "transport" responsible for getting SQL queries to a
17
- database, and streaming results back through a ` Query ` instance.
18
- - [ Query] [ ] - a [ Readable] [ ] stream that emits row objects.
14
+ - [ Queryable] [ ] - a common interface implemented by connections, pools, and
15
+ transactions.
16
+ - [ Connection] [ ] - the "transport" responsible for getting SQL queries to a
17
+ database, and streaming results back through a ` Query ` instance.
18
+ - [ Query] [ ] - a [ Readable] [ ] stream that emits row objects.
19
19
20
20
## Callbacks
21
21
@@ -38,9 +38,10 @@ Queryable := EventEmitter & {
38
38
```
39
39
40
40
Known implementations:
41
- - [ Connection] [ Connection ]
42
- - [ ConnectionPool] [ ConnectionPool ] (external)
43
- - [ Transaction] [ Transaction ] (external).
41
+
42
+ - [ Connection] [ connection ]
43
+ - [ ConnectionPool] [ connectionpool ] (external)
44
+ - [ Transaction] [ transaction ] (external).
44
45
45
46
### Queryable.adapter
46
47
@@ -64,21 +65,26 @@ The second form is not needed for normal use, but must be implemented by
64
65
adapters to work correctly with [ ConnectionPool] [ ] and [ Transaction] [ ] . See
65
66
[ Adapter.createQuery] ( #adapter-createquery ) for more details.
66
67
67
- * Callback-style*
68
+ _ Callback-style_
69
+
68
70
``` javascript
69
- queryable .query (' SELECT * FROM my_table' , function (err , res ) {
71
+ queryable .query (' SELECT * FROM my_table' , function (err , res ) {
70
72
if (err) return console .error (err)
71
73
res .rows .forEach (console .log )
72
74
console .log (' All done!' )
73
75
})
74
76
```
75
77
76
- * Stream-style*
78
+ _ Stream-style_
79
+
77
80
``` javascript
78
- queryable .query (' SELECT * FROM my_table' )
81
+ queryable
82
+ .query (' SELECT * FROM my_table' )
79
83
.on (' error' , console .error )
80
84
.on (' data' , console .log )
81
- .on (' end' , function () { console .log (' All done!' ) })
85
+ .on (' end' , function () {
86
+ console .log (' All done!' )
87
+ })
82
88
```
83
89
84
90
### Queryable events
@@ -89,7 +95,7 @@ The `'query'` event is emitted immediately before a query is executed.
89
95
90
96
One argument is passed to event handlers:
91
97
92
- * ` query ` - a [ Query] [ ] object
98
+ - ` query ` - a [ Query] [ ] object
93
99
94
100
## Connection
95
101
@@ -101,9 +107,9 @@ Connection := Queryable & {
101
107
102
108
Known implementations:
103
109
104
- - [ any-db-mysql] [ ] (external)
105
- - [ any-db-postgres] [ ] (external)
106
- - [ any-db-sqlite3] [ ] (external)
110
+ - [ any-db-mysql] [ ] (external)
111
+ - [ any-db-postgres] [ ] (external)
112
+ - [ any-db-sqlite3] [ ] (external)
107
113
108
114
Connection objects are obtained using [ createConnection] [ ] from [ Any-DB] [ ] or
109
115
[ ConnectionPool.acquire] [ ] , both of which delegate to the
@@ -154,32 +160,32 @@ Query := Readable<Object> & {
154
160
}
155
161
```
156
162
157
- ` Query ` objects are returned by the [ Queryable.query] [ Queryable .query] method,
158
- available on [ connections] [ Connection ] , [ pools] [ ConnectionPool .query] , and
159
- [ transactions] [ Transaction .query] . Queries are instances of [ Readable] [ ] , and
160
- as such can be [ piped] [ Readable .pipe] through transforms and support backpressure
163
+ ` Query ` objects are returned by the [ Queryable.query] [ queryable .query] method,
164
+ available on [ connections] [ connection ] , [ pools] [ connectionpool .query] , and
165
+ [ transactions] [ transaction .query] . Queries are instances of [ Readable] [ ] , and
166
+ as such can be [ piped] [ readable .pipe] through transforms and support backpressure
161
167
for more efficient memory-usage on very large results sets. (Note: at this time
162
168
the ` sqlite3 ` driver does not support backpressure)
163
169
164
170
Internally, ` Query ` instances are
165
- [ created by a database Adapter] [ Adapter.createQuery ] and may have more methods,
171
+ [ created by a database Adapter] [ adapter.createquery ] and may have more methods,
166
172
properties, and events than are described here. Consult the documentation for
167
173
your specific adapter to find out about any extensions.
168
174
169
175
### Query.text
170
176
171
177
The SQL query as a string. If you are using MySQL this will contain
172
- interpolated values * after * the query has been enqueued by a connection.
178
+ interpolated values _ after _ the query has been enqueued by a connection.
173
179
174
180
### Query.values
175
181
176
182
The array of parameter values.
177
183
178
184
### Query.callback
179
185
180
- The callback (if any) that was provided to [ Queryable.query] [ Queryable .query] .
186
+ The callback (if any) that was provided to [ Queryable.query] [ queryable .query] .
181
187
Note that ` Query ` objects ** must not** use a closed over reference to their
182
- callback, as other ` any-db ` libraries * may * rely on modifying the ` callback `
188
+ callback, as other ` any-db ` libraries _ may _ rely on modifying the ` callback `
183
189
property of a ` Query ` they did not create.
184
190
185
191
### Query Events
@@ -192,15 +198,15 @@ be subscribed to the `'error'` event.
192
198
193
199
One argument is passed to event listeners:
194
200
195
- * ` error ` - the error object.
201
+ - ` error ` - the error object.
196
202
197
203
#### Fields event
198
204
199
205
A ` 'fields' ` event is emmitted before any ` 'data' ` events.
200
206
201
207
One argument is passed to event listeners:
202
208
203
- * ` fields ` - an array of [ Field] [ ResultSet ] objects.
209
+ - ` fields ` - an array of [ Field] [ resultset ] objects.
204
210
205
211
### [ Readable] [ ] events
206
212
@@ -212,7 +218,7 @@ A `'data'` event is emitted for each row in the query result set.
212
218
213
219
One argument is passed to event listeners:
214
220
215
- * ` row ` contains the contents of a single row in the query result
221
+ - ` row ` contains the contents of a single row in the query result
216
222
217
223
#### Close event
218
224
@@ -242,7 +248,7 @@ Field := {
242
248
}
243
249
```
244
250
245
- ` ResultSet ` objects are just plain data that collect results of a query when a
251
+ ` ResultSet ` objects are just plain data that collect results of a query when a
246
252
continuation is provided to [ Queryable.query] [ ] . The ` lastInsertId ` is optional,
247
253
and currently supported by ` sqlite3 ` and ` mysql ` but not ` postgres ` , because
248
254
it is not supported by Postgres itself.
@@ -283,7 +289,7 @@ See also: the [Connection API](#connection)
283
289
(Query) => Query {* returns same Query *}
284
290
```
285
291
286
- Create a [ Query] ( #query ) that * may * eventually be executed later on by a
292
+ Create a [ Query] ( #query ) that _ may _ eventually be executed later on by a
287
293
[ Connection] [ ] . While this function is rarely needed by user code, it makes
288
294
it possible for [ ConnectionPool.query] [ ] and [ Transaction.query] [ ] to fulfill
289
295
the [ Queryable.query] [ ] contract by synchronously returning a [ Query] [ ] stream.
@@ -299,23 +305,20 @@ the [Queryable.query][] contract by synchronously returning a [Query][] stream.
299
305
[ any-db-mysql ] : https://github.com/grncdr/node-any-db-mysql
300
306
[ any-db-postgres ] : https://github.com/grncdr/node-any-db-postgres
301
307
[ any-db-sqlite3 ] : https://github.com/grncdr/node-any-db-sqlite3
302
- [ createConnection ] : https://github.com/grncdr/node-any-db#exportscreateconnection
303
-
304
- [ Readable ] : http://nodejs.org/api/stream.html#stream_class_stream_readable
305
- [ Readable.pipe ] : http://nodejs.org/api/stream.html#stream_readable_pipe_destination_options
306
-
307
- [ ConnectionPool.query ] : https://github.com/grncdr/node-any-db-pool#connectionpoolquery
308
- [ ConnectionPool.acquire ] : https://github.com/grncdr/node-any-db-pool#connectionpoolacquire
309
- [ ConnectionPool ] : https://github.com/grncdr/node-any-db-pool#api
310
- [ Transaction ] : https://github.com/grncdr/node-any-db-transaction#api
308
+ [ createconnection ] : https://github.com/grncdr/node-any-db#exportscreateconnection
309
+ [ readable ] : http://nodejs.org/api/stream.html#stream_class_stream_readable
310
+ [ readable.pipe ] : http://nodejs.org/api/stream.html#stream_readable_pipe_destination_options
311
+ [ connectionpool.query ] : https://github.com/grncdr/node-any-db-pool#connectionpoolquery
312
+ [ connectionpool.acquire ] : https://github.com/grncdr/node-any-db-pool#connectionpoolacquire
313
+ [ connectionpool ] : https://github.com/grncdr/node-any-db-pool#api
314
+ [ transaction ] : https://github.com/grncdr/node-any-db-transaction#api
311
315
[ any-db-transaction ] : https://github.com/grncdr/node-any-db-transaction
312
- [ Transaction.query ] : https://github.com/grncdr/node-any-db-transaction#transactionquery
313
-
316
+ [ transaction.query ] : https://github.com/grncdr/node-any-db-transaction#transactionquery
314
317
[ test suite ] : tests
315
- [ Adapter ] : #adapter
316
- [ Queryable ] : #queryable
317
- [ Queryable .query] : #queryablequery
318
- [ Connection ] : #connection
319
- [ Connection .query] : #connectionquery
320
- [ Query ] : #query
321
- [ Adapter.createQuery ] : #adaptercreatequery
318
+ [ adapter ] : #adapter
319
+ [ queryable ] : #queryable
320
+ [ queryable .query] : #queryablequery
321
+ [ connection ] : #connection
322
+ [ connection .query] : #connectionquery
323
+ [ query ] : #query
324
+ [ adapter.createquery ] : #adaptercreatequery
0 commit comments