duckdb 0.4.1-dev1265.0 → 0.4.1-dev1287.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.
package/lib/duckdb.js CHANGED
@@ -1,13 +1,79 @@
1
+ /**
2
+ * @module duckdb
3
+ * @summary these jsdoc annotations are still a work in progress - feedback and suggestions are welcome!
4
+ */
5
+
1
6
  var duckdb = require('./duckdb-binding.js');
2
7
  module.exports = exports = duckdb;
3
8
 
9
+ /**
10
+ * Check that errno attribute equals this to check for a duckdb error
11
+ * @constant {number}
12
+ */
13
+ var ERROR = duckdb.ERROR;
14
+
15
+ /**
16
+ * Open database in readonly mode
17
+ * @constant {number}
18
+ */
19
+ var OPEN_READONLY = duckdb.OPEN_READONLY;
20
+ /**
21
+ * Currently ignored
22
+ * @constant {number}
23
+ */
24
+ var OPEN_READWRITE = duckdb.OPEN_READWRITE;
25
+ /**
26
+ * Currently ignored
27
+ * @constant {number}
28
+ */
29
+ var OPEN_CREATE = duckdb.OPEN_CREATE;
30
+ /**
31
+ * Currently ignored
32
+ * @constant {number}
33
+ */
34
+ var OPEN_FULLMUTEX = duckdb.OPEN_FULLMUTEX;
35
+ /**
36
+ * Currently ignored
37
+ * @constant {number}
38
+ */
39
+ var OPEN_SHAREDCACHE = duckdb.OPEN_SHAREDCACHE;
40
+ /**
41
+ * Currently ignored
42
+ * @constant {number}
43
+ */
44
+ var OPEN_PRIVATECACHE = duckdb.OPEN_PRIVATECACHE;
4
45
 
5
46
  // some wrappers for compatibilities sake
47
+ /**
48
+ * Main database interface
49
+ */
6
50
  var Database = duckdb.Database;
51
+ /**
52
+ * @class
53
+ */
7
54
  var Connection = duckdb.Connection;
55
+ /**
56
+ * @class
57
+ */
8
58
  var Statement = duckdb.Statement;
59
+ /**
60
+ * @class
61
+ */
9
62
  var QueryResult = duckdb.QueryResult;
10
63
 
64
+ /**
65
+ * @method
66
+ * @return data chunk
67
+ */
68
+ QueryResult.prototype.nextChunk;
69
+
70
+ /**
71
+ * @name asyncIterator
72
+ * @memberof module:duckdb~QueryResult
73
+ * @method
74
+ * @instance
75
+ * @yields data chunks
76
+ */
11
77
  QueryResult.prototype[Symbol.asyncIterator] = async function*() {
12
78
  let prefetch = this.nextChunk();
13
79
  while (true) {
@@ -25,22 +91,45 @@ QueryResult.prototype[Symbol.asyncIterator] = async function*() {
25
91
  }
26
92
 
27
93
 
28
- Connection.prototype.run = function(sql) {
94
+ /**
95
+ * @arg sql
96
+ * @param {...*} params
97
+ * @param callback
98
+ * @return {void}
99
+ */
100
+ Connection.prototype.run = function (sql) {
29
101
  var statement = new Statement(this, sql);
30
102
  return statement.run.apply(statement, arguments);
31
103
  }
32
104
 
33
- Connection.prototype.all = function(sql) {
34
- var statement = new Statement(this,sql);
105
+ /**
106
+ * @arg sql
107
+ * @param {...*} params
108
+ * @param callback
109
+ * @return {void}
110
+ */
111
+ Connection.prototype.all = function (sql) {
112
+ var statement = new Statement(this, sql);
35
113
  return statement.all.apply(statement, arguments);
36
114
  }
37
115
 
38
- Connection.prototype.each = function(sql) {
116
+ /**
117
+ * @arg sql
118
+ * @param {...*} params
119
+ * @param callback
120
+ * @return {void}
121
+ */
122
+ Connection.prototype.each = function (sql) {
39
123
  var statement = new Statement(this, sql);
40
124
  return statement.each.apply(statement, arguments);
41
125
  }
42
126
 
43
- Connection.prototype.stream = async function*(sql) {
127
+ /**
128
+ * @arg sql
129
+ * @param {...*} params
130
+ * @yields row chunks
131
+ */
132
+ Connection.prototype.stream = async function* (sql) {
44
133
  const statement = new Statement(this, sql);
45
134
  const queryResult = await statement.stream.apply(statement, arguments);
46
135
  for await (const result of queryResult) {
@@ -48,10 +137,18 @@ Connection.prototype.stream = async function*(sql) {
48
137
  }
49
138
  }
50
139
 
51
- // this follows the wasm udfs somewhat but is simpler because we can pass data much more cleanly
52
- Connection.prototype.register = function(name, return_type, fun) {
140
+ /**
141
+ * Register a User Defined Function
142
+ *
143
+ * @arg name
144
+ * @arg return_type
145
+ * @arg fun
146
+ * @return {void}
147
+ * @note this follows the wasm udfs somewhat but is simpler because we can pass data much more cleanly
148
+ */
149
+ Connection.prototype.register = function (name, return_type, fun) {
53
150
  // TODO what if this throws an error somewhere? do we need a try/catch?
54
- return this.register_bulk(name, return_type, function(desc) {
151
+ return this.register_bulk(name, return_type, function (desc) {
55
152
  try {
56
153
  // Build an argument resolver
57
154
  const buildResolver = (arg) => {
@@ -151,62 +248,236 @@ Connection.prototype.register = function(name, return_type, fun) {
151
248
  desc.ret.data[i] = res;
152
249
  desc.ret.validity[i] = res === undefined || res === null ? 0 : 1;
153
250
  }
154
- } catch(error) { // work around recently fixed napi bug https://github.com/nodejs/node-addon-api/issues/912
251
+ } catch (error) { // work around recently fixed napi bug https://github.com/nodejs/node-addon-api/issues/912
155
252
  console.log(desc.ret);
156
253
  msg = error;
157
254
  if (typeof error == 'object' && 'message' in error) {
158
255
  msg = error.message
159
256
  }
160
- throw {name: 'DuckDB-UDF-Exception', message : msg};
257
+ throw { name: 'DuckDB-UDF-Exception', message: msg };
161
258
  }
162
259
  })
163
260
  }
164
261
 
165
- default_connection = function(o) {
262
+ /**
263
+ * @method
264
+ * @arg sql
265
+ * @param {...*} params
266
+ * @param callback
267
+ * @return {Statement}
268
+ */
269
+ Connection.prototype.prepare;
270
+ /**
271
+ * @method
272
+ * @arg sql
273
+ * @param {...*} params
274
+ * @param callback
275
+ * @return {void}
276
+ */
277
+ Connection.prototype.exec;
278
+ /**
279
+ * Register a User Defined Function
280
+ *
281
+ * @method
282
+ * @arg name
283
+ * @arg return_type
284
+ * @param callback
285
+ * @return {void}
286
+ */
287
+ Connection.prototype.register_bulk;
288
+ /**
289
+ * Unregister a User Defined Function
290
+ *
291
+ * @method
292
+ * @arg name
293
+ * @arg return_type
294
+ * @param callback
295
+ * @return {void}
296
+ */
297
+ Connection.prototype.unregister;
298
+
299
+ default_connection = function (o) {
166
300
  if (o.default_connection == undefined) {
167
301
  o.default_connection = new duckdb.Connection(o);
168
302
  }
169
- return(o.default_connection);
303
+ return o.default_connection;
170
304
  }
171
305
 
172
- Database.prototype.prepare = function() {
306
+
307
+ /**
308
+ * @method
309
+ * @param callback
310
+ * @return {void}
311
+ */
312
+ Database.prototype.close;
313
+
314
+ /**
315
+ * @method
316
+ * @param callback
317
+ * TODO: what does this do?
318
+ * @return {void}
319
+ */
320
+ Database.prototype.wait;
321
+
322
+ /**
323
+ * TODO: what does this do?
324
+ * @method
325
+ * @param callback
326
+ * @return {void}
327
+ */
328
+ Database.prototype.serialize;
329
+
330
+ /**
331
+ * TODO: what does this do?
332
+ * @method
333
+ * @param callback
334
+ * @return {void}
335
+ */
336
+ Database.prototype.parallelize;
337
+
338
+ /**
339
+ * @method
340
+ * @arg path the database to connect to, either a file path, or `:memory:`
341
+ * @return {Connection}
342
+ */
343
+ Database.prototype.connect;
344
+
345
+ /**
346
+ * TODO: what does this do?
347
+ * @method
348
+ * @param callback
349
+ * @return {void}
350
+ */
351
+ Database.prototype.interrupt;
352
+
353
+ /**
354
+ * @arg sql
355
+ * @return {Statement}
356
+ */
357
+ Database.prototype.prepare = function () {
173
358
  return default_connection(this).prepare.apply(this.default_connection, arguments);
174
359
  }
175
360
 
176
- Database.prototype.run = function() {
361
+ /**
362
+ * @arg sql
363
+ * @param {...*} params
364
+ * @param callback
365
+ * @return {void}
366
+ */
367
+ Database.prototype.run = function () {
177
368
  default_connection(this).run.apply(this.default_connection, arguments);
178
369
  return this;
179
370
  }
180
371
 
181
- Database.prototype.each = function() {
372
+ /**
373
+ * @arg sql
374
+ * @param {...*} params
375
+ * @param callback
376
+ * @return {void}
377
+ */
378
+ Database.prototype.each = function () {
182
379
  default_connection(this).each.apply(this.default_connection, arguments);
183
380
  return this;
184
381
  }
185
382
 
186
- Database.prototype.all = function() {
383
+ /**
384
+ * @arg sql
385
+ * @param {...*} params
386
+ * @param callback
387
+ * @return {void}
388
+ */
389
+ Database.prototype.all = function () {
187
390
  default_connection(this).all.apply(this.default_connection, arguments);
188
391
  return this;
189
392
  }
190
393
 
191
- Database.prototype.exec = function() {
394
+ /**
395
+ * @arg sql
396
+ * @param {...*} params
397
+ * @param callback
398
+ * @return {void}
399
+ */
400
+ Database.prototype.exec = function () {
192
401
  default_connection(this).exec.apply(this.default_connection, arguments);
193
402
  return this;
194
403
  }
195
404
 
196
- Database.prototype.register = function() {
405
+ /**
406
+ * Register a User Defined Function
407
+ *
408
+ * Convenience method for Connection#register
409
+ * @arg name
410
+ * @arg return_type
411
+ * @arg fun
412
+ * @return {this}
413
+ */
414
+ Database.prototype.register = function () {
197
415
  default_connection(this).register.apply(this.default_connection, arguments);
198
416
  return this;
199
417
  }
200
418
 
201
- Database.prototype.unregister = function() {
419
+ /**
420
+ * Unregister a User Defined Function
421
+ *
422
+ * Convenience method for Connection#unregister
423
+ * @arg name
424
+ * @return {this}
425
+ */
426
+ Database.prototype.unregister = function () {
202
427
  default_connection(this).unregister.apply(this.default_connection, arguments);
203
428
  return this;
204
429
  }
205
430
 
206
- Database.prototype.get = function() {
431
+ /**
432
+ * Not implemented
433
+ */
434
+ Database.prototype.get = function () {
207
435
  throw "get() is not implemented because it's evil";
208
436
  }
209
437
 
210
- Statement.prototype.get = function() {
438
+ /**
439
+ * Not implemented
440
+ */
441
+ Statement.prototype.get = function () {
211
442
  throw "get() is not implemented because it's evil";
212
443
  }
444
+
445
+ /**
446
+ * @method
447
+ * @arg sql
448
+ * @param {...*} params
449
+ * @param callback
450
+ * @return {void}
451
+ */
452
+ Statement.prototype.run;
453
+ /**
454
+ * @method
455
+ * @arg sql
456
+ * @param {...*} params
457
+ * @param callback
458
+ * @return {void}
459
+ */
460
+ Statement.prototype.all;
461
+ /**
462
+ * @method
463
+ * @arg sql
464
+ * @param {...*} params
465
+ * @param callback
466
+ * @return {void}
467
+ */
468
+ Statement.prototype.each;
469
+ /**
470
+ * @method
471
+ * @arg sql
472
+ * @param {...*} params
473
+ * @param callback
474
+ * @return {void}
475
+ */
476
+ Statement.prototype.finalize
477
+ /**
478
+ * @method
479
+ * @arg sql
480
+ * @param {...*} params
481
+ * @yield callback
482
+ */
483
+ Statement.prototype.stream;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "duckdb",
3
3
  "main": "./lib/duckdb.js",
4
- "version": "0.4.1-dev1265.0",
4
+ "version": "0.4.1-dev1287.0",
5
5
  "description": "DuckDB node.js API",
6
6
  "gypfile": true,
7
7
  "dependencies": {
@@ -26,6 +26,8 @@
26
26
  },
27
27
  "devDependencies": {
28
28
  "aws-sdk": "^2.790.0",
29
+ "chai": "^4.3.6",
30
+ "jsdoc3-parser": "^2.0.0",
29
31
  "mocha": "^8.3.0"
30
32
  },
31
33
  "repository": {
package/src/duckdb.hpp CHANGED
@@ -11,8 +11,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
11
11
  #pragma once
12
12
  #define DUCKDB_AMALGAMATION 1
13
13
  #define DUCKDB_AMALGAMATION_EXTENDED 1
14
- #define DUCKDB_SOURCE_ID "5d25704f9"
15
- #define DUCKDB_VERSION "v0.4.1-dev1265"
14
+ #define DUCKDB_SOURCE_ID "7863fb7e1"
15
+ #define DUCKDB_VERSION "v0.4.1-dev1287"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //