monetdb 1.3.3 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/.github/workflows/Linux.yml +45 -0
  2. package/.github/workflows/docs.yml +79 -0
  3. package/.github/workflows/macos.yml +43 -0
  4. package/.github/workflows/monetdb-versions.yml +43 -0
  5. package/README.md +43 -512
  6. package/docs/components/alert.tsx +10 -0
  7. package/docs/components/info.tsx +6 -0
  8. package/docs/next.config.js +24 -0
  9. package/docs/package-lock.json +5069 -0
  10. package/docs/package.json +22 -0
  11. package/docs/pages/_app.js +9 -0
  12. package/docs/pages/_meta.json +16 -0
  13. package/docs/pages/apis/_meta.json +4 -0
  14. package/docs/pages/apis/connection.mdx +60 -0
  15. package/docs/pages/apis/result.mdx +39 -0
  16. package/docs/pages/index.mdx +27 -0
  17. package/docs/theme.config.js +35 -0
  18. package/docs/v1/README.md +532 -0
  19. package/package.json +17 -21
  20. package/src/PrepareStatement.ts +37 -0
  21. package/src/connection.ts +125 -0
  22. package/src/defaults.ts +13 -0
  23. package/src/file-transfer.ts +173 -0
  24. package/src/index.ts +3 -0
  25. package/src/mapi.ts +1016 -0
  26. package/src/monetize.ts +67 -0
  27. package/test/connection.ts +43 -0
  28. package/test/exec-queries.ts +100 -0
  29. package/test/filetransfer.ts +94 -0
  30. package/test/prepare-statement.ts +27 -0
  31. package/test/query-stream.ts +41 -0
  32. package/test/tmp/.gitignore +4 -0
  33. package/tsconfig.json +24 -0
  34. package/.travis.yml +0 -11
  35. package/index.js +0 -5
  36. package/src/mapi-connection.js +0 -784
  37. package/src/monetdb-connection.js +0 -385
  38. package/src/utils.js +0 -27
  39. package/test/common.js +0 -45
  40. package/test/install-monetdb.sh +0 -11
  41. package/test/monetdb_stream.js +0 -106
  42. package/test/start-monetdb.sh +0 -38
  43. package/test/test.js +0 -908
  44. package/test/test_connection.js +0 -290
  45. /package/docs/{README.v0.md → v0/README.v0.md} +0 -0
  46. /package/docs/{MapiConnection.md → v1/MapiConnection.md} +0 -0
  47. /package/docs/{v1-notes.md → v1/v1-notes.md} +0 -0
package/README.md CHANGED
@@ -1,531 +1,62 @@
1
- # MonetDB NodeJS connector version 1.\*
1
+ # MonetDB Node.js
2
2
 
3
- [![Build Status](https://travis-ci.org/MonetDB/monetdb-nodejs.svg)](https://travis-ci.org/MonetDB/monetdb-nodejs)
4
- [![Coverage Status](https://coveralls.io/repos/MonetDB/monetdb-nodejs/badge.svg?branch=master&service=github)](https://coveralls.io/github/MonetDB/monetdb-nodejs?branch=master)
3
+ [![Linux](https://github.com/MonetDB/monetdb-nodejs/workflows/Linux/badge.svg)
4
+ [![macOS](https://github.com/MonetDB/monetdb-nodejs/workflows/macos/badge.svg)
5
5
  [![npm version](https://badge.fury.io/js/monetdb.svg)](https://badge.fury.io/js/monetdb)
6
- [![Dependency Status](https://david-dm.org/MonetDB/monetdb-nodejs.svg)](https://david-dm.org/MonetDB/monetdb-nodejs)
7
6
 
7
+ Node.js connector for MonetDB.
8
8
 
9
- This NodeJS module provides an easy and powerful way to use MonetDB inside your NodeJS programs.
9
+ ## Getting Started
10
10
 
11
-
12
- For version 0.\* users:
13
- * **[Click here for documentation of version 0.\*](https://github.com/MonetDB/monetdb-nodejs/blob/master/docs/README.v0.md)**
14
- * **[Click here for update notes, including new features, backward compatibility notes, and upgrade instructions](https://github.com/MonetDB/monetdb-nodejs/blob/master/docs/v1-notes.md)**
15
-
16
-
17
- <a name="example"></a>
18
- ## Example usage
19
-
20
- ```javascript
21
- var MDB = require('monetdb')();
22
-
23
- var options = {
24
- host : 'localhost',
25
- port : 50000,
26
- dbname : 'mydb',
27
- user : 'monetdb',
28
- password : 'monetdb'
29
- };
30
-
31
- var conn = new MDB(options);
32
- conn.connect();
33
-
34
- conn.query('SELECT * FROM mytable').then(function(result) {
35
- // Do something with the result
36
- });
37
-
38
- conn.close();
11
+ ```bash
12
+ npm install monetdb
39
13
  ```
14
+ , connect with default options
40
15
 
16
+ ```js
17
+ import { Connection } from monetdb
41
18
 
42
-
43
- <a name="options"></a>
44
- # Options
45
- There are three flavors of setting options:
46
- 1. providing global options
47
- 2. providing local options
48
- 3. changing local options
49
-
50
- Let's look at how we could use these flavors to setup connections for multiple users:
51
-
52
- ```javascript
53
- // We set the global option 'dbname' to 'db', for all connections
54
- var MDB = require('monetdb')({dbname: 'db'});
55
-
56
- // We can now create two connections for different users
57
- // Both connections will use the globally set 'dbname' option
58
- var conn1 = new MDB({user: 'foo', password: 'bar'});
59
- var conn2 = new MDB({user: 'dumb', password: '0000'});
60
-
61
- // Now let's change a local option of conn1
62
- // (which is only possible for non-connection specific options)
63
- conn1.option("setMaxReconnects", 1);
64
- ```
65
-
66
- In general, the order in which options are consider is:
67
- 1. local
68
- 2. global
69
- 3. default (if available)
70
-
71
- The MonetDB NodeJS module recognizes many options.
72
- You do not need to know them all.
73
- There is **only one** option that does not have a default value, and that is the database name (dbname).
74
-
75
- The available options can be subdivided into several categories:
76
-
77
-
78
- ### Connection options
79
- These options are used to make the actual connection to MonetDB. Note that these options can not be changed with the
80
- [MonetDBConnection.option](#mdbconnection_option) method.
81
- If you want to change these settings on an open connection, just construct a new connection.
82
-
83
- | Option | Type | Default | Additional description |
84
- | :---------------- | :-------- | :------------------------------ | :--------------------- |
85
- | host | string | localhost |
86
- | port | integer | 50000 |
87
- | dbname | string | | No default value for this one.
88
- | user | string | monetdb |
89
- | password | string | monetdb |
90
- | language | string | sql | The language of the issued queries. Should be one of sql/mal.
91
- | defaultSchema | string | sys | The default schema to set the connection to after connecting.
92
- | timezoneOffset | integer | offset of current timezone | The offset in minutes that holds for the required timezone. See [connection timezone](#timezone) for more info.
93
- | autoCommit | boolean | true | Set auto_commit flag
94
-
95
-
96
- ### Reconnection options
97
- These options are used to determine how to reconnect whenever a connection fails.
98
-
99
- | Option | Type | Default | Additional description |
100
- | :---------- | :-------- | :------------------------------ | :--------------------- |
101
- | maxReconnects | integer | 10 | The maximum number of reconnect attempts after a connection failure. Set to 0 if you do not want to reconnect on connection failures.
102
- | reconnectTimeout | integer | 2000 | The timeout used in between reconnect attempts.
103
-
104
-
105
- ### Query options
106
- These options influence the way queries are executed.
107
-
108
- | Option | Type | Default | Additional description |
109
- | :---------------- | :-------- | :------------------------------ | :--------------------- |
110
- | prettyResult | boolean | false | The value for this option will be the default value for how query results are returned. This can be overwritten on a per-query basis. See [pretty results](#pretty) for more info.
111
-
112
- ### Logging
113
- The MonetDB NodeJS module comes with a very extensive logging functionality. It distinguishes between many types of different
114
- messages, and allows you to fully customize the way the MonetDB NodeJS module deals with log messages when they occur.
115
- See the [logging section](#logging) for more information.
116
-
117
- | Option | Type | Default | Additional description |
118
- | :---------------- | :-------- | :------------------------------ | :--------------------- |
119
- | logger | function | console.log | This function will be used by all of the default logging functions.
120
- | warnings | boolean | true | Whether or not to log warnings. **It is highly adviced to keep this set to true, otherwise you will not be notified on e.g. unrecognized options or reconnection attempts.**
121
- | warningFn | function | See [logging section](#logging) | Warning messages will be passed to this function when they occur.
122
- | debug | boolean | false | Whether or not to log general debug messages.
123
- | debugFn | function | See [logging section](#logging) | Debug messages will be passed to this function when they occur.
124
- | debugRequests | boolean | false | Whether or not to log requests (SQL or MAL) when they resolve.
125
- | debugRequestFn | function | See [logging section](#logging) | SQL or MAL requests, including their results, will be passed to this function when they occur.
126
- | debugMapi | boolean | false | Whether or not to show the Mapi messages that are being sent back and forth between the MonetDB NodeJS module and the MonetDB server.
127
- | debugMapiFn | function | See [logging section](#logging) | Mapi messages will be passed to this function when they occur.
128
-
129
-
130
-
131
- ### Testing
132
- Options provided solely for testing.
133
-
134
- | Option | Type | Default | Additional description |
135
- | :---------------- | :-------- | :------------------------------ | :--------------------- |
136
- | testing | boolean | false | When set to true, some additional (undocumented) methods will be exposed, e.g. to simulate socket failures.
137
-
138
-
139
-
140
-
141
-
142
-
143
-
144
- <a name="mdbconnection"></a>
145
- # MonetDBConnection
146
-
147
- Getting a MonetDBConnection object is easy:
148
-
149
- ```javascript
150
- var MDB = require('monetdb')();
151
-
152
- // MDB is a constructor function; let's construct a MonetDBConnection object, shall we?
153
- var conn = new MDB({dbname: 'mydb'});
154
-
155
- // conn now is a MonetDBConnection object
156
- ```
157
-
158
- All of its exposed attributes and methods are listed here:
159
-
160
-
161
- <a name="mdbconnection_constructor"></a>
162
- ### MonetDBConnection(\[options\])
163
- Constructor for a MonetDBConnection object, that takes an optional options object. For possible options, see the
164
- [options section](#options).
165
-
166
- Throws an error when the provided options object is not ok.
167
-
168
-
169
-
170
- <a name="mdbconnection_mapiconnection"></a>
171
- ### .mapiConnection
172
- Instance of MapiConnection. This attribute will be managed by the MonetDBConnection object, so in normal cases you should
173
- not use this. Only if you want to e.g. fire raw queries against the database, you might want to reference it directly.
174
- Just in case you are wondering,
175
- [here is the documentation](https://github.com/MonetDB/monetdb-nodejs/blob/master/docs/MapiConnection.md).
176
-
177
-
178
-
179
- <a name="mdbconnection_connect"></a>
180
- ### .connect()
181
- *This method links to [MapiConnection.connect](https://github.com/MonetDB/monetdb-nodejs/blob/master/docs/MapiConnection.md#connect)*
182
-
183
- Open the connection to the MonetDB server.
184
-
185
- Returns a promise that resolves when the connection succeeded, and gets rejected with an error message otherwise.
186
- Note that you **do not have to wait** for the connection promise to be resolved before issueing queries, since incoming
187
- queries will be properly cached.
188
-
189
-
190
-
191
- ### .open()
192
- Alias for [MonetDBConnection.connect](#mdbconnection_connect).
193
-
194
-
195
-
196
- <a name="mdbconnection_query"></a>
197
- ### .query(query, \[params\], \[prettyResult\])
198
- Issue a query against the database. For a simple example, [see here](#example).
199
-
200
- | Argument | Type | Required | Description |
201
- | :------------ | :------------ | :------------- | :-------------- |
202
- | query | string | yes | The query you want to run. In case language is sql, this should be a valid SQL query.
203
- | params | array | no | If this array is given, a prepared statement will be used under the hood. Very useful if you want to easily protect against SQL injection.
204
- | prettyResult | boolean | no | If this is set to true, the query result will be prettified. If not given, the default from the options is used. See the [pretty result section](#pretty) for more info.
205
-
206
- Example of a query with parameters:
207
- ```javascript
208
- var MDB = require('monetdb')();
209
-
210
- var conn = new MDB({dbname: 'mydb'});
211
- conn.connect();
212
-
213
- conn.query(
214
- 'SELECT * FROM mytable WHERE c < ? AND d > ?',
215
- [40, 102]
216
- ).then(function(result) {
217
- // Do something with the result
218
- });
219
- ```
220
-
221
- Returns a promise that resolves with an object with the following properties:
222
-
223
- | Property | Type | Description |
224
- | :--------------------- | :--------------------- | :-------------- |
225
- | data | array\[array\|object\] | If this is the result of a SELECT query, this property contains the resulting data returned by the database. Every array entry represents one row of the result set. If the 'prettyResult' option was set to true, every array entry will be an object, where the object properties equal the column names. Otherwise, the array entries will be arrays containing just the column values.
226
- | col | object | Object maps column names to query result indices. So if you for example did SELECT a, b FROM ... you can access b in a tuple array by issuing tuple[result.col.b], which in this case would resolve to tuple[1].
227
- | rows | integer | The number of rows in the result set.
228
- | cols | integer | The number of columns in the result set.
229
- | structure | array\[object\] | An array containing an object for every column, with column information.
230
- | structure\[i\].table | string | The name of the table to which column i belongs.
231
- | structure\[i\].column | string | The name of column i.
232
- | structure\[i\].type | string | The database type of column i.
233
- | structure\[i\].typelen | integer | The length in the database of column i.
234
- | structure\[i\].index | index | The array index of column i, which will equal i.
235
- | queryid | integer | A unique identifier for this query.
236
- | type | string | The type of the result (currently only 'table' is supported).
237
-
238
-
239
- ### .querystream(query)
240
- Stream monetdb response.
241
-
242
- Example:
243
- ```javascript
244
- var MDB = require('monetdb')();
245
-
246
- var conn = new MDB({dbname: 'mydb'});
247
- conn.connect();
248
-
249
- function test_stream (conn, sql) {
250
- let result;
251
- return new Promise((resolve, reject) => {
252
- conn.querystream(sql)
253
- .on('error', (err) => {
254
- return reject(err);
255
- })
256
- .on('header', (header) => {
257
- "add header to result"
258
-
259
- })
260
- .on('data', (data) => {
261
- "add data to result"
262
- })
263
- .on('end', () => {
264
- "all rows being received"
265
- resolve(result);
266
- });
267
- });
19
+ const opt: MapiConfig = {
20
+ database: 'your_database'
268
21
  }
269
- ```
270
22
 
271
- ### .request(query, \[params\], \[prettyResult\])
272
- Alias for [MonetDBConnection.query](#mdbconnection_query).
273
-
274
-
275
-
276
- <a name="mdbconnection_prepare"></a>
277
- ### .prepare(query, \[prettyResult\])
278
- Prepares a query for repeated execution, and generates execution and release convenience functions.
279
-
280
- | Argument | Type | Required | Description |
281
- | :------------ | :------------ | :------------- | :-------------- |
282
- | query | string | yes | The query that has to be prepared. If it does not start with prepare (case insensitive), 'PREPARE ' will be prepended to the query.
283
- | prettyResult | boolean | no | If this is set to true, the exec function will return prettified results. If not given, the default from the options is used. See the [pretty result section](#pretty) for more info.
284
-
285
- Returns a promise that resolves with an object with the following properties:
286
-
287
- | Property | Type | Description |
288
- | :--------------------- | :----------- | :-------------- |
289
- | prepare | object | The regular query result for the PREPARE statement, as is described under [MonetDBConnection.query](#mdbconnection_query).
290
- | exec | function | A function that executes the prepared statement. As its first and only argument, it takes an array of values. It returns a promise equivalent to the promise returned by [MonetDBConnection.query](#mdbconnection_query).
291
- | release | function | A parameterless function that you can call when you want to free the resources used by the prepared statement. After calling this function, calls to the exec function will fail. This function **does not** return anything. You cannot be notified of whether or not this worked.
292
-
293
- Example:
294
-
295
- ```javascript
296
- var MDB = require('monetdb')();
297
-
298
- var conn = new MDB({dbname: 'mydb'});
299
- conn.connect();
300
-
301
- conn.prepare('SELECT * FROM mytable WHERE c < ? AND d > ?').then(function(prepResult) {
302
- // execute query twice
303
- prepResult.exec([10, 5]).then(function(result) {
304
- // do something with the result
305
- });
306
- prepResult.exec([50, -20]).then(function(result) {
307
- // do something with the result
308
- });
309
-
310
- // we are done, release it (and do not wait for it, release method does not return a promise)
311
- prepResult.release();
312
- });
313
- ```
314
-
315
-
316
- <a name="mdbconnection_env"></a>
317
- ### .env()
318
- Get the connection environment. Example:
319
-
320
- ```javascript
321
- var MDB = require('monetdb')();
322
-
323
- var conn = new MDB({dbname: 'mydb'});
324
- conn.connect();
325
-
326
- conn.env().then(function(env) {
327
- console.log(env);
328
- });
329
- ```
330
-
331
- Will output:
332
-
333
- ```
334
- {
335
- "gdk_dbpath": "/home/robin/dbfarm/test",
336
- "gdk_debug": "0",
337
- "gdk_vmtrim": "no",
338
- ..
339
- ```
340
-
341
-
342
- <a name="mdbconnection_option"></a>
343
- ### .option(name, [value])
344
- Get or set an option.
345
-
346
- | Argument | Type | Required | Description |
347
- | :------------ | :------------------ | :------------- | :-------------- |
348
- | name | string | yes | The name of the option. See the [option section](#options) for the recognized options.
349
- | value | depending on option | no | If this argument is provided, it is assumed that you want to set the option to this argument. Note that setting options is not possible for connection options. The connection options are mentioned in the [option section](#options).
350
-
351
- Throws an error if either the provided option is not found, or if the provided value is invalid.
352
-
353
- If the second argument is omitted, the value of the option is returned.
354
-
355
-
356
- <a name="mdbconnection_getstate"></a>
357
- ### .getState()
358
- *This method links to [MapiConnection.getState](https://github.com/MonetDB/monetdb-nodejs/blob/master/docs/MapiConnection.md#getstate)*
359
-
360
- Get the current state of the connection. For normal usage you will never need to use this.
361
-
362
- Returns one of the following state strings:
363
-
364
- | State | Meaning |
365
- | :------------ | :------------ |
366
- | disconnected | There is currently no open connection, either because it has never been opened yet, or because a reconnect is going on.
367
- | connected | There is an open connection to the server, but authentication has not finished yet.
368
- | ready | There is an open connection to the server, and we have successfully authenticated. The connection is ready to accept queries.
369
- | destroyed | The connection is destroyed, either because it was explicitly destroyed by a call to [MonetDBConnection.destroy](#mdbconnection_destroy), or because of a failure to keep the connection open.
370
-
371
- Regardless of the return value of this method, you can safely issue queries to the connection, since they will be properly queued until the connection is ready.
372
-
373
-
374
-
375
- <a name="mdbconnection_close"></a>
376
- ### .close()
377
- *This method links to [MapiConnection.close](https://github.com/MonetDB/monetdb-nodejs/blob/master/docs/MapiConnection.md#close)*
378
-
379
- Finishes all the current queries in the queue, and then destroys the socket by calling [MonetDBConnection.destroy](#mdbconnection_destroy).
380
- After closing a connection, it cannot be reopened. If reopening is desired, you should create a [new MonetDBConnection object](#mdbconnection_constructor).
381
-
382
- When queries are issued after calling close, they are still accepted and put into the queue, so a connection remains active
383
- until it becomes idle.
384
-
385
- Note that when you have issued a query with parameters, this will under the hood be executed in two steps (one prepare step
386
- and one execution step). If the close method is called after firing a prepared statement, it might therefore fail because the
387
- socket can be destroyed after finishing the first step.
388
-
389
- Returns a promise that resolves when all queries in the queue are done and the socket is destroyed.
390
-
391
-
392
-
393
- ### .disconnect()
394
- Alias for [MonetDBConnection.close](#mdbconnection_close).
395
-
396
-
397
-
398
- <a name="mdbconnection_destroy"></a>
399
- ### .destroy(\[msg\])
400
- *This method links to [MapiConnection.destroy](https://github.com/MonetDB/monetdb-nodejs/blob/master/docs/MapiConnection.md#destroy)*
401
-
402
- Fails all queries currently in the queue (including the one that is currently being executed), and destroys the socket.
403
-
404
- | Argument | Type | Required | Description |
405
- | :------------ | :------------------ | :------------- | :-------------- |
406
- | msg | string | no | An error message that will be sent to all queries that are rejected. If none is given, a default error message is sent.
407
-
408
-
409
- ### .getCallbackWrapper()
410
- This method is added for backward compatability. For information on how to use it, see
411
- [the updates page](https://github.com/MonetDB/monetdb-nodejs/blob/master/docs/update.md#callbackwrapper).
412
-
413
-
414
-
415
- <a name="pretty"></a>
416
- # Pretty query results
417
- By default, every row in a query result is represented by an array. However, if the pretty flag is set, the query result
418
- will instead be an array of objects, where every object has the column names as its properties. This makes using the result
419
- a lot more intuitive and fault-tolerant (e.g. if you hard code indices into row arrays, your code might start failing
420
- when you change the SQL query).
421
- The default value of the pretty flag can be overwritten by providing the global or local option 'prettyResult'. Even then,
422
- you can override this default value on a per query basis, by providing a boolean value as last argument to either the
423
- [MonetDBConnection.query](#mdbconnection_query) or the [MonetDBConnection.prepare](#mdbconnection_prepare) function.
424
- Example:
425
-
426
- ```javascript
427
- var MDB = require('monetdb')();
428
-
429
- var conn = new MDB({dbname: 'mydb'});
430
- conn.connect();
431
-
432
- // we did not set the option 'prettyResult', hence we will pass true to our queries to have them return prettified results.
433
- conn.query("SELECT a, b FROM yourtable").then(function(result) {
434
- console.log(result.data);
435
- });
23
+ const conn = new Connection(opt);
436
24
  ```
25
+ , or using mapi URL
437
26
 
438
- Outputs (depending on the values of columnns a and b and the number of resulting tuples):
27
+ ```js
28
+ import { Connection } from monetdb
29
+ const conn = new Connection('mapi:monetdb://<username>:<password>@<hostname>:<port>/<database>');
439
30
  ```
440
- [
441
- { a: 'val1', b: 'val2' },
442
- { a: 'val3', b: 'val4' }
443
- ]
31
+ , then run some queries
32
+ ```js
33
+ const ready: boolean = await conn.connect();
34
+ const res: QueryResult = await conn.execute('select 42');
35
+ ...
36
+ const closed: boolean = await conn.close();
444
37
  ```
38
+ , for detailed api documentation please visit [documentation](https://monetdb.github.io/monetdb-nodejs/).
39
+ ## Features
40
+ - prepared statements
41
+ - streaming query results
42
+ - bulk import & export with `COPY TO/COPY FROM`
43
+ ## Contributing
445
44
 
45
+ **We :heart: contributions!**
446
46
 
47
+ We will **happily** accept your pull request if it:
447
48
 
448
- <a name="timezone"></a>
449
- # Connection time zone
450
- For every connection that is opened to the server, the timezone is automatically set to the current timezone of the system
451
- that opens the connection. You can change this behavior by passing a value for the [option 'timezoneOffset'](#options).
452
- The value for this option represents the number of minutes to deviate from GMT.
453
- This value is used by MonetDB to present timestamps with timezone. Example:
454
-
455
- ```javascript
456
- var MDB = require('monetdb')();
457
-
458
- // Create two connections with different time zone
459
-
460
- // One GMT+02:00
461
- var conn1 = new MDB({timezoneOffset: 120, dbname: 'mydb'});
462
-
463
- // And one GMT-03:30 (= -210 minutes)
464
- var conn2 = new MDB({timezoneOffset: -210, dbname: 'mydb'});
465
-
466
- conn1.connect();
467
- conn2.connect();
468
-
469
- conn1.query('SELECT NOW').then(function(result) {
470
- // result.data[0][0] will be something like '2015-11-02 08:11:31.000000+02:00'
471
- });
472
-
473
- conn2.query('SELECT NOW').then(function(result) {
474
- // result.data[0][0] will be something like '2015-11-02 02:45:56.000000-03:30'
475
- });
476
- ```
477
-
478
-
479
-
480
- <a name="logging"></a>
481
- # Logging
482
- As you can see from the [options section](#options), there are many logging options. By default, only warning messages
483
- are logged, and console.log is used for this. The following types of log events can occur:
484
- 1. Warnings
485
- * Unrecognized options
486
- * Connection failures
487
- * Queries are issued before calling [connect()](#mdbconnection_connect)
488
- 2. Debug messages
489
- * State changes (see
490
- [MapiConnection object](https://github.com/MonetDB/monetdb-nodejs/blob/master/docs/MapiConnection.md#getstate)
491
- for possible states)
492
- * Read/write counts on opened socket
493
- 3. Resolved requests
494
- 4. Mapi messages
495
-
496
- You can manipulate whether or not these events are logged or not, and which functions are used to do this.
497
- For all of these events, a default log function is specified in
498
- [utils.js](https://github.com/MonetDB/monetdb-nodejs/blob/master/src/utils.js)
499
- Every log function receives as its first argument the logger that it should use, where the logger simply
500
- takes a string and logs it somewhere. By default, the logger is **console.log**. You can change this in
501
- the [options](#options).
502
-
503
- In case you want to overwrite the default log functions, here are the function signatures:
504
-
505
- ### options.warningFn(logger, msg)
506
-
507
- | Argument | Type | Description |
508
- | :------------ | :------------------- | :-------------- |
509
- | logger | function | The logger that is used, which defaults to console.log but can be specified through the [options](#options).
510
- | msg | string | The message to write to the provided logger.
511
-
512
- ### options.debugFn(logger, msg)
513
- Same as options.warningFn
514
-
515
- ### options.debugRequestFn(logger, request, error, result)
516
-
517
- | Argument | Type | Description |
518
- | :------------ | :------------------- | :-------------- |
519
- | logger | function | The logger that is used, which defaults to console.log but can be specified through the [options](#options).
520
- | request | string | The request message (SQL query string in case this request is an SQL query)
521
- | error | Error|null | If this request failed, this argument contains the error that was thrown. Otherwise, this argument will be null.
522
- | result | Object|null | If this request passed, this argument contains the [resulting object](#mdbconnection_query).
49
+ - **has tests**
50
+ - looks reasonable
51
+ - does not break backwards compatibility
523
52
 
524
- ### options.debugMapiFn(logger, type, msg)
53
+ If your change has breaking backwards compatibility please please point that out in the pull request. When you open an issue please provide:
54
+ - version of Node
55
+ - version of MonetDB
56
+ - smallest possible snippet of code to reproduce the problem
57
+ ### Setting up for local development
58
+ - clone the repo
59
+ - run ``` npm i && npm run build``` in root folder
60
+ - have MonetDB running with `test` database. For more information on how to get started with MonetDB please visit [MonetDB Documentation](https://www.monetdb.org/documentation-Jun2023/user-guide/get-started/)
61
+ - run tests with `npm t`
525
62
 
526
- | Argument | Type | Description |
527
- | :------------ | :------------------- | :-------------- |
528
- | logger | function | The logger that is used, which defaults to console.log but can be specified through the [options](#options).
529
- | type | string | Either 'TX' for transmitted messages, or 'RX' for received messages.
530
- | msg | string | The string that was communicated over the socket.
531
-
@@ -0,0 +1,10 @@
1
+ import React from 'react'
2
+ import { Callout } from 'nextra-theme-docs'
3
+
4
+ export const Alert = ({ children }) => {
5
+ return (
6
+ <Callout type="warning" emoji="⚠️">
7
+ {children}
8
+ </Callout>
9
+ )
10
+ }
@@ -0,0 +1,6 @@
1
+ import React from 'react'
2
+ import { Callout } from 'nextra-theme-docs'
3
+
4
+ export const Info = ({ children }) => {
5
+ return <Callout emoji="ℹ️">{children}</Callout>
6
+ }
@@ -0,0 +1,24 @@
1
+ // next.config.js
2
+ const withNextra = require('nextra')({
3
+ theme: 'nextra-theme-docs',
4
+ themeConfig: './theme.config.js',
5
+ })
6
+
7
+ const isProduction = process.env.NODE_ENV === "production";
8
+ const assetPrefix = isProduction ? "/monetdb-nodejs" : "";
9
+
10
+ const nextConfig = {
11
+ output: "export",
12
+ distDir: 'dist',
13
+ images: {
14
+ unoptimized: true,
15
+ },
16
+ trailingSlash: true,
17
+ assetPrefix,
18
+ basePath: assetPrefix,
19
+ }
20
+
21
+ module.exports = {
22
+ ... withNextra(),
23
+ ...nextConfig
24
+ }