oracledb 5.5.0 → 6.0.1
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/CHANGELOG.md +1 -1875
- package/LICENSE.txt +8 -222
- package/NOTICE.txt +1 -1
- package/README.md +38 -30
- package/SECURITY.md +38 -0
- package/build/Release/oracledb-6.0.1-darwin-x64.node +0 -0
- package/build/Release/oracledb-6.0.1-darwin-x64.node-buildinfo.txt +1 -0
- package/build/Release/oracledb-6.0.1-js-buildinfo.txt +1 -0
- package/build/Release/oracledb-6.0.1-linux-arm64.node +0 -0
- package/build/Release/oracledb-6.0.1-linux-arm64.node-buildinfo.txt +1 -0
- package/build/Release/oracledb-6.0.1-linux-x64.node +0 -0
- package/build/Release/oracledb-6.0.1-linux-x64.node-buildinfo.txt +1 -0
- package/build/Release/oracledb-6.0.1-win32-x64.node +0 -0
- package/build/Release/oracledb-6.0.1-win32-x64.node-buildinfo.txt +1 -0
- package/examples/README.md +113 -0
- package/examples/dbconfig.js +100 -0
- package/examples/example.js +156 -0
- package/index.js +26 -0
- package/lib/aqDeqOptions.js +148 -8
- package/lib/aqEnqOptions.js +59 -7
- package/lib/aqMessage.js +118 -7
- package/lib/aqQueue.js +243 -53
- package/lib/connection.js +1326 -465
- package/lib/constants.js +203 -0
- package/lib/dbObject.js +346 -32
- package/lib/errors.js +785 -0
- package/lib/impl/aqDeqOptions.js +197 -0
- package/lib/impl/aqEnqOptions.js +89 -0
- package/lib/impl/aqMessage.js +134 -0
- package/lib/impl/aqQueue.js +81 -0
- package/lib/impl/connection.js +529 -0
- package/lib/impl/dbObject.js +159 -0
- package/lib/impl/index.js +59 -0
- package/lib/impl/lob.js +85 -0
- package/lib/impl/pool.js +195 -0
- package/lib/impl/resultset.js +223 -0
- package/lib/impl/sodaCollection.js +174 -0
- package/lib/impl/sodaDatabase.js +81 -0
- package/lib/impl/sodaDocCursor.js +63 -0
- package/lib/impl/sodaDocument.js +98 -0
- package/lib/impl/sodaOperation.js +109 -0
- package/lib/lob.js +157 -68
- package/lib/oracledb.js +1047 -345
- package/lib/pool.js +654 -465
- package/lib/poolStatistics.js +24 -9
- package/lib/queryStream.js +16 -8
- package/lib/resultset.js +291 -183
- package/lib/settings.js +191 -0
- package/lib/sodaCollection.js +214 -201
- package/lib/sodaDatabase.js +108 -71
- package/lib/sodaDocCursor.js +44 -32
- package/lib/sodaDocument.js +76 -14
- package/lib/sodaOperation.js +131 -118
- package/lib/thin/connection.js +1043 -0
- package/lib/thin/dbObject.js +630 -0
- package/lib/thin/index.js +40 -0
- package/lib/thin/lob.js +189 -0
- package/lib/thin/pool.js +481 -0
- package/lib/thin/protocol/buffer.js +1043 -0
- package/lib/thin/protocol/capabilities.js +121 -0
- package/lib/thin/protocol/constants.js +765 -0
- package/lib/thin/protocol/encryptDecrypt.js +185 -0
- package/lib/thin/protocol/messages/auth.js +349 -0
- package/lib/thin/protocol/messages/base.js +476 -0
- package/lib/thin/protocol/messages/commit.js +56 -0
- package/lib/thin/protocol/messages/dataType.js +391 -0
- package/lib/thin/protocol/messages/execute.js +312 -0
- package/lib/thin/protocol/messages/fetch.js +60 -0
- package/lib/thin/protocol/messages/index.js +53 -0
- package/lib/thin/protocol/messages/lobOp.js +201 -0
- package/lib/thin/protocol/messages/logOff.js +53 -0
- package/lib/thin/protocol/messages/ping.js +56 -0
- package/lib/thin/protocol/messages/protocol.js +78 -0
- package/lib/thin/protocol/messages/rollback.js +56 -0
- package/lib/thin/protocol/messages/sessionRelease.js +60 -0
- package/lib/thin/protocol/messages/withData.js +812 -0
- package/lib/thin/protocol/oson.js +661 -0
- package/lib/thin/protocol/packet.js +519 -0
- package/lib/thin/protocol/protocol.js +202 -0
- package/lib/thin/protocol/utils.js +89 -0
- package/lib/thin/resultSet.js +122 -0
- package/lib/thin/sqlnet/connStrategy.js +175 -0
- package/lib/thin/sqlnet/constants.js +199 -0
- package/lib/thin/sqlnet/ezConnectResolver.js +488 -0
- package/lib/thin/sqlnet/navNodes.js +870 -0
- package/lib/thin/sqlnet/networkSession.js +621 -0
- package/lib/thin/sqlnet/ntTcp.js +527 -0
- package/lib/thin/sqlnet/nvStrToNvPair.js +783 -0
- package/lib/thin/sqlnet/packet.js +405 -0
- package/lib/thin/sqlnet/paramParser.js +206 -0
- package/lib/thin/sqlnet/sessionAtts.js +160 -0
- package/lib/thin/statement.js +300 -0
- package/lib/thin/util.js +289 -0
- package/lib/transformer.js +252 -0
- package/lib/types.js +357 -0
- package/lib/util.js +196 -110
- package/lib/version.js +36 -0
- package/package/README.md +33 -30
- package/package/install.js +89 -64
- package/package/prunebinaries.js +60 -12
- package/package.json +3 -3
- package/build/Release/oracledb-5.5.0-darwin-x64.node +0 -0
- package/build/Release/oracledb-5.5.0-darwin-x64.node-buildinfo.txt +0 -1
- package/build/Release/oracledb-5.5.0-linux-x64.node +0 -0
- package/build/Release/oracledb-5.5.0-linux-x64.node-buildinfo.txt +0 -1
- package/build/Release/oracledb-5.5.0-win32-x64.node +0 -0
- package/build/Release/oracledb-5.5.0-win32-x64.node-buildinfo.txt +0 -1
package/lib/settings.js
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
// Copyright (c) 2022, 2023, Oracle and/or its affiliates.
|
|
2
|
+
|
|
3
|
+
//-----------------------------------------------------------------------------
|
|
4
|
+
//
|
|
5
|
+
// This software is dual-licensed to you under the Universal Permissive License
|
|
6
|
+
// (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License
|
|
7
|
+
// 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose
|
|
8
|
+
// either license.
|
|
9
|
+
//
|
|
10
|
+
// If you elect to accept the software under the Apache License, Version 2.0,
|
|
11
|
+
// the following applies:
|
|
12
|
+
//
|
|
13
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
14
|
+
// you may not use this file except in compliance with the License.
|
|
15
|
+
// You may obtain a copy of the License at
|
|
16
|
+
//
|
|
17
|
+
// https://www.apache.org/licenses/LICENSE-2.0
|
|
18
|
+
//
|
|
19
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
20
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
21
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
22
|
+
// See the License for the specific language governing permissions and
|
|
23
|
+
// limitations under the License.
|
|
24
|
+
//
|
|
25
|
+
//-----------------------------------------------------------------------------
|
|
26
|
+
|
|
27
|
+
'use strict';
|
|
28
|
+
|
|
29
|
+
const constants = require('./constants.js');
|
|
30
|
+
const errors = require('./errors.js');
|
|
31
|
+
const types = require('./types.js');
|
|
32
|
+
|
|
33
|
+
class Settings {
|
|
34
|
+
|
|
35
|
+
constructor() {
|
|
36
|
+
this.autoCommit = false;
|
|
37
|
+
this.connectionClass = '';
|
|
38
|
+
this.dbObjectAsPojo = false;
|
|
39
|
+
this.edition = '';
|
|
40
|
+
this.errorOnConcurrentExecute = false;
|
|
41
|
+
this.events = false;
|
|
42
|
+
this.externalAuth = false;
|
|
43
|
+
this.fetchArraySize = 100;
|
|
44
|
+
this.fetchAsBuffer = [];
|
|
45
|
+
this.fetchAsString = [];
|
|
46
|
+
this.lobPrefetchSize = 16384;
|
|
47
|
+
this.maxRows = 0;
|
|
48
|
+
this.outFormat = constants.OUT_FORMAT_ARRAY;
|
|
49
|
+
this.poolIncrement = 1;
|
|
50
|
+
this.poolMax = 4;
|
|
51
|
+
this.poolMaxPerShard = 0;
|
|
52
|
+
this.poolMin = 0;
|
|
53
|
+
this.poolPingInterval = 60;
|
|
54
|
+
this.poolTimeout = 60;
|
|
55
|
+
this.prefetchRows = 2;
|
|
56
|
+
this.queueTimeout = 60000;
|
|
57
|
+
this.queueMax = 500;
|
|
58
|
+
this.stmtCacheSize = 30;
|
|
59
|
+
this.thin = true;
|
|
60
|
+
this.thinDriverInitialized = false;
|
|
61
|
+
this.createFetchTypeMap(this.fetchAsString, this.fetchAsBuffer);
|
|
62
|
+
this.fetchTypeHandler = undefined;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
//---------------------------------------------------------------------------
|
|
66
|
+
// _getDateComponents()
|
|
67
|
+
//
|
|
68
|
+
// Returns the components of a date. DATE and TIMESTAMP data from the
|
|
69
|
+
// database are returned as though they used the JavaScript time zone
|
|
70
|
+
// setting. TIMESTAMP WITH TIME ZONE and TIMESTAMP WITH LOCAL TIME ZONE data
|
|
71
|
+
// are returned in native JavaScript format (since they contain time zone
|
|
72
|
+
// information).
|
|
73
|
+
//---------------------------------------------------------------------------
|
|
74
|
+
_getDateComponents(useLocal, date) {
|
|
75
|
+
if (useLocal) {
|
|
76
|
+
return [
|
|
77
|
+
date.getFullYear(),
|
|
78
|
+
date.getMonth() + 1,
|
|
79
|
+
date.getDate(),
|
|
80
|
+
date.getHours(),
|
|
81
|
+
date.getMinutes(),
|
|
82
|
+
date.getSeconds(),
|
|
83
|
+
date.getMilliseconds() * 1000 * 1000
|
|
84
|
+
];
|
|
85
|
+
} else {
|
|
86
|
+
return [
|
|
87
|
+
date.getUTCFullYear(),
|
|
88
|
+
date.getUTCMonth() + 1,
|
|
89
|
+
date.getUTCDate(),
|
|
90
|
+
date.getUTCHours(),
|
|
91
|
+
date.getUTCMinutes(),
|
|
92
|
+
date.getUTCSeconds(),
|
|
93
|
+
date.getUTCMilliseconds() * 1000 * 1000
|
|
94
|
+
];
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
//---------------------------------------------------------------------------
|
|
99
|
+
// _makeDate()
|
|
100
|
+
//
|
|
101
|
+
// Returns a date from the given components. DATE and TIMESTAMP data from the
|
|
102
|
+
// database are returned as though they used the JavaScript time zone
|
|
103
|
+
// setting. TIMESTAMP WITH TIME ZONE and TIMESTAMP WITH LOCAL TIME ZONE data
|
|
104
|
+
// are returned in native JavaScript format (since they contain time zone
|
|
105
|
+
// information).
|
|
106
|
+
//---------------------------------------------------------------------------
|
|
107
|
+
_makeDate(useLocal, year, month, day, hour, minute, second, fseconds, offset) {
|
|
108
|
+
if (useLocal) {
|
|
109
|
+
return new Date(year, month - 1, day, hour, minute, second, fseconds);
|
|
110
|
+
}
|
|
111
|
+
return new Date(Date.UTC(year, month - 1, day, hour, minute, second,
|
|
112
|
+
fseconds) - offset * 60000);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
//---------------------------------------------------------------------------
|
|
116
|
+
// addToOptions()
|
|
117
|
+
//
|
|
118
|
+
// Adds the named settingsto the options, if no option has already been
|
|
119
|
+
// specified.
|
|
120
|
+
//---------------------------------------------------------------------------
|
|
121
|
+
addToOptions(options) {
|
|
122
|
+
for (let i = 1; i < arguments.length; i++) {
|
|
123
|
+
const key = arguments[i];
|
|
124
|
+
if (options[key] === undefined)
|
|
125
|
+
options[key] = this[key];
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
//---------------------------------------------------------------------------
|
|
130
|
+
// createFetchTypeMap()
|
|
131
|
+
//
|
|
132
|
+
// Creates the fetch type map. This overrides the default fetch type mapping
|
|
133
|
+
// used by the driver with the contents of the fetchAsString and
|
|
134
|
+
// fetchAsBuffer arrays. The error checking is performed here as well in
|
|
135
|
+
// order to eliminate repeated code.
|
|
136
|
+
// ---------------------------------------------------------------------------
|
|
137
|
+
createFetchTypeMap(fetchAsString, fetchAsBuffer) {
|
|
138
|
+
|
|
139
|
+
// create a copy of the default fetch type map
|
|
140
|
+
const map = new Map(types.DB_TYPE_FETCH_TYPE_MAP);
|
|
141
|
+
|
|
142
|
+
// adjust map for fetchAsString settings
|
|
143
|
+
for (const element of fetchAsString) {
|
|
144
|
+
switch (element) {
|
|
145
|
+
case types.DB_TYPE_NUMBER:
|
|
146
|
+
map.set(types.DB_TYPE_BINARY_DOUBLE, types.DB_TYPE_VARCHAR);
|
|
147
|
+
map.set(types.DB_TYPE_BINARY_FLOAT, types.DB_TYPE_VARCHAR);
|
|
148
|
+
map.set(types.DB_TYPE_BINARY_INTEGER, types.DB_TYPE_VARCHAR);
|
|
149
|
+
map.set(types.DB_TYPE_NUMBER, types.DB_TYPE_VARCHAR);
|
|
150
|
+
break;
|
|
151
|
+
case types.DB_TYPE_TIMESTAMP:
|
|
152
|
+
map.set(types.DB_TYPE_DATE, types.DB_TYPE_VARCHAR);
|
|
153
|
+
map.set(types.DB_TYPE_TIMESTAMP, types.DB_TYPE_VARCHAR);
|
|
154
|
+
map.set(types.DB_TYPE_TIMESTAMP_TZ, types.DB_TYPE_VARCHAR);
|
|
155
|
+
map.set(types.DB_TYPE_TIMESTAMP_LTZ, types.DB_TYPE_VARCHAR);
|
|
156
|
+
break;
|
|
157
|
+
case types.DB_TYPE_CLOB:
|
|
158
|
+
case types.DB_TYPE_NCLOB:
|
|
159
|
+
map.set(types.DB_TYPE_CLOB, types.DB_TYPE_LONG);
|
|
160
|
+
map.set(types.DB_TYPE_NCLOB, types.DB_TYPE_LONG_NVARCHAR);
|
|
161
|
+
break;
|
|
162
|
+
case types.DB_TYPE_RAW:
|
|
163
|
+
map.set(types.DB_TYPE_RAW, types.DB_TYPE_VARCHAR);
|
|
164
|
+
break;
|
|
165
|
+
case types.DB_TYPE_JSON:
|
|
166
|
+
map.set(types.DB_TYPE_JSON, types.DB_TYPE_VARCHAR);
|
|
167
|
+
break;
|
|
168
|
+
default:
|
|
169
|
+
errors.throwErr(errors.ERR_INVALID_TYPE_FOR_CONVERSION);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// adjust map for fetchAsBuffer settings
|
|
174
|
+
for (const element of fetchAsBuffer) {
|
|
175
|
+
switch (element) {
|
|
176
|
+
case types.DB_TYPE_BLOB:
|
|
177
|
+
map.set(types.DB_TYPE_BLOB, types.DB_TYPE_LONG_RAW);
|
|
178
|
+
break;
|
|
179
|
+
default:
|
|
180
|
+
errors.throwErr(errors.ERR_INVALID_TYPE_FOR_CONVERSION);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// assign calculated fetchTypeMap for later use
|
|
185
|
+
this.fetchTypeMap = map;
|
|
186
|
+
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
module.exports = new Settings();
|
package/lib/sodaCollection.js
CHANGED
|
@@ -1,17 +1,24 @@
|
|
|
1
|
-
// Copyright (c) 2018,
|
|
1
|
+
// Copyright (c) 2018, 2023, Oracle and/or its affiliates.
|
|
2
2
|
|
|
3
3
|
//-----------------------------------------------------------------------------
|
|
4
4
|
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
5
|
+
// This software is dual-licensed to you under the Universal Permissive License
|
|
6
|
+
// (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License
|
|
7
|
+
// 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose
|
|
8
|
+
// either license.
|
|
7
9
|
//
|
|
10
|
+
// If you elect to accept the software under the Apache License, Version 2.0,
|
|
11
|
+
// the following applies:
|
|
12
|
+
//
|
|
13
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
14
|
+
// you may not use this file except in compliance with the License.
|
|
8
15
|
// You may obtain a copy of the License at
|
|
9
|
-
// http://www.apache.org/licenses/LICENSE-2.0.
|
|
10
16
|
//
|
|
11
|
-
//
|
|
12
|
-
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
13
|
-
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
+
// https://www.apache.org/licenses/LICENSE-2.0
|
|
14
18
|
//
|
|
19
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
20
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
21
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
22
|
// See the License for the specific language governing permissions and
|
|
16
23
|
// limitations under the License.
|
|
17
24
|
//
|
|
@@ -19,238 +26,244 @@
|
|
|
19
26
|
|
|
20
27
|
'use strict';
|
|
21
28
|
|
|
29
|
+
const SodaDocument = require('./sodaDocument.js');
|
|
30
|
+
const SodaOperation = require('./sodaOperation.js');
|
|
31
|
+
const errors = require('./errors.js');
|
|
22
32
|
const nodbUtil = require('./util.js');
|
|
33
|
+
const settings = require('./settings.js');
|
|
23
34
|
|
|
24
|
-
|
|
25
|
-
// drop()
|
|
26
|
-
// Drop the collection.
|
|
27
|
-
//-----------------------------------------------------------------------------
|
|
28
|
-
async function drop() {
|
|
29
|
-
nodbUtil.checkArgCount(arguments, 0, 0);
|
|
30
|
-
return await this._drop();
|
|
31
|
-
}
|
|
32
|
-
|
|
35
|
+
class SodaCollection {
|
|
33
36
|
|
|
34
|
-
|
|
35
|
-
//
|
|
36
|
-
//
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
//---------------------------------------------------------------------------
|
|
38
|
+
// createIndex()
|
|
39
|
+
//
|
|
40
|
+
// Create an index on the collection.
|
|
41
|
+
//---------------------------------------------------------------------------
|
|
42
|
+
async createIndex(spec) {
|
|
43
|
+
errors.assertArgCount(arguments, 1, 1);
|
|
44
|
+
errors.assertParamValue(nodbUtil.isObject(spec), 1);
|
|
45
|
+
const options = {autoCommit: settings.autoCommit};
|
|
46
|
+
return await this._impl.createIndex(JSON.stringify(spec), options);
|
|
47
|
+
}
|
|
41
48
|
|
|
42
|
-
|
|
43
|
-
|
|
49
|
+
//---------------------------------------------------------------------------
|
|
50
|
+
// drop()
|
|
51
|
+
//
|
|
52
|
+
// Drop the collection.
|
|
53
|
+
//---------------------------------------------------------------------------
|
|
54
|
+
async drop() {
|
|
55
|
+
errors.assertArgCount(arguments, 0, 0);
|
|
56
|
+
const options = {autoCommit: settings.autoCommit};
|
|
57
|
+
return await this._impl.drop(options);
|
|
44
58
|
}
|
|
45
59
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
60
|
+
//---------------------------------------------------------------------------
|
|
61
|
+
// dropIndex()
|
|
62
|
+
//
|
|
63
|
+
// Drop an index on the collection.
|
|
64
|
+
//---------------------------------------------------------------------------
|
|
65
|
+
async dropIndex(indexName, a2) {
|
|
66
|
+
const options = {autoCommit: settings.autoCommit};
|
|
67
|
+
|
|
68
|
+
errors.assertArgCount(arguments, 1, 2);
|
|
69
|
+
errors.assertParamValue(typeof indexName === 'string', 1);
|
|
70
|
+
if (arguments.length == 2) {
|
|
71
|
+
errors.assertParamValue(typeof a2 === 'object', 2);
|
|
72
|
+
if (a2.force !== undefined) {
|
|
73
|
+
errors.assertParamPropValue(typeof a2.force === 'boolean', 2, "force");
|
|
74
|
+
options.force = a2.force;
|
|
75
|
+
}
|
|
51
76
|
}
|
|
52
|
-
|
|
77
|
+
return await this._impl.dropIndex(indexName, options);
|
|
53
78
|
}
|
|
54
79
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
let options = {};
|
|
66
|
-
|
|
67
|
-
nodbUtil.checkArgCount(arguments, 1, 2);
|
|
68
|
-
nodbUtil.assert(Array.isArray(docs), 'NJS-005', 1);
|
|
69
|
-
|
|
70
|
-
if (arguments.length == 2) {
|
|
71
|
-
nodbUtil.assert(nodbUtil.isObject(a2), 'NJS-005', 2);
|
|
72
|
-
options = a2;
|
|
80
|
+
//---------------------------------------------------------------------------
|
|
81
|
+
// find()
|
|
82
|
+
//
|
|
83
|
+
// Returns a SODA operation associated with the collection.
|
|
84
|
+
//---------------------------------------------------------------------------
|
|
85
|
+
find() {
|
|
86
|
+
errors.assertArgCount(arguments, 0, 0);
|
|
87
|
+
const op = new SodaOperation();
|
|
88
|
+
op._impl = this._impl.find();
|
|
89
|
+
return op;
|
|
73
90
|
}
|
|
74
91
|
|
|
75
|
-
|
|
76
|
-
|
|
92
|
+
//---------------------------------------------------------------------------
|
|
93
|
+
// getDataGuide()
|
|
94
|
+
// Return the data guide for the collection.
|
|
95
|
+
//---------------------------------------------------------------------------
|
|
96
|
+
async getDataGuide() {
|
|
97
|
+
errors.assertArgCount(arguments, 0, 0);
|
|
98
|
+
const doc = new SodaDocument();
|
|
99
|
+
doc._impl = await this._impl.getDataGuide();
|
|
100
|
+
return doc;
|
|
77
101
|
}
|
|
78
102
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
103
|
+
//---------------------------------------------------------------------------
|
|
104
|
+
// insertMany()
|
|
105
|
+
//
|
|
106
|
+
// Insert an array of documents into the collection in a single round-trip.
|
|
107
|
+
//---------------------------------------------------------------------------
|
|
108
|
+
async insertMany(docs) {
|
|
109
|
+
errors.assertArgCount(arguments, 1, 1);
|
|
110
|
+
errors.assertParamValue(Array.isArray(docs) && docs.length > 0, 1);
|
|
111
|
+
|
|
112
|
+
let actualDocs = Array(docs.length);
|
|
113
|
+
for (let i = 0; i < docs.length; i++) {
|
|
114
|
+
actualDocs[i] = nodbUtil.verifySodaDoc(docs[i]);
|
|
84
115
|
}
|
|
85
|
-
actualDocs[i] = content;
|
|
86
|
-
}
|
|
87
116
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
//-----------------------------------------------------------------------------
|
|
93
|
-
// insertOne()
|
|
94
|
-
// Inserts a single document into the collection.
|
|
95
|
-
//-----------------------------------------------------------------------------
|
|
96
|
-
async function insertOne(content) {
|
|
97
|
-
nodbUtil.checkArgCount(arguments, 1, 1);
|
|
98
|
-
nodbUtil.assert(nodbUtil.isObject(content) ||
|
|
99
|
-
nodbUtil.isSodaDocument(content), 'NJS-005', 1);
|
|
100
|
-
|
|
101
|
-
if (!nodbUtil.isSodaDocument(content)) {
|
|
102
|
-
content = Buffer.from(JSON.stringify(content));
|
|
117
|
+
const options = {autoCommit: settings.autoCommit};
|
|
118
|
+
await this._impl.insertMany(actualDocs, options);
|
|
103
119
|
}
|
|
104
120
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
121
|
+
//---------------------------------------------------------------------------
|
|
122
|
+
// insertManyAndGet()
|
|
123
|
+
//
|
|
124
|
+
// Insert an array of documents into the collection in a single round-trip
|
|
125
|
+
// and return a set of result documents containing metadata.
|
|
126
|
+
//---------------------------------------------------------------------------
|
|
127
|
+
async insertManyAndGet(docs, a2) {
|
|
128
|
+
const options = {autoCommit: settings.autoCommit};
|
|
129
|
+
|
|
130
|
+
errors.assertArgCount(arguments, 1, 2);
|
|
131
|
+
errors.assertParamValue(Array.isArray(docs) && docs.length > 0, 1);
|
|
132
|
+
|
|
133
|
+
if (arguments.length == 2) {
|
|
134
|
+
errors.assertParamValue(nodbUtil.isObject(a2), 2);
|
|
135
|
+
if (a2.hint !== undefined) {
|
|
136
|
+
errors.assertParamPropValue(typeof a2.hint === 'string', 2, "hint");
|
|
137
|
+
options.hint = a2.hint;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
108
140
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
//-----------------------------------------------------------------------------
|
|
114
|
-
async function insertOneAndGet(content, a2) {
|
|
115
|
-
let options = {};
|
|
141
|
+
const actualDocs = Array(docs.length);
|
|
142
|
+
for (let i = 0; i < docs.length; i++) {
|
|
143
|
+
actualDocs[i] = nodbUtil.verifySodaDoc(docs[i]);
|
|
144
|
+
}
|
|
116
145
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
146
|
+
const docImpls = await this._impl.insertManyAndGet(actualDocs, options);
|
|
147
|
+
for (let i = 0; i < docs.length; i++) {
|
|
148
|
+
const doc = actualDocs[i] = new SodaDocument();
|
|
149
|
+
doc._impl = docImpls[i];
|
|
150
|
+
}
|
|
120
151
|
|
|
121
|
-
|
|
122
|
-
nodbUtil.assert(nodbUtil.isObject(a2), 'NJS-005', 2);
|
|
123
|
-
options = a2;
|
|
152
|
+
return actualDocs;
|
|
124
153
|
}
|
|
125
154
|
|
|
126
|
-
|
|
127
|
-
|
|
155
|
+
//---------------------------------------------------------------------------
|
|
156
|
+
// insertOne()
|
|
157
|
+
//
|
|
158
|
+
// Inserts a single document into the collection.
|
|
159
|
+
//---------------------------------------------------------------------------
|
|
160
|
+
async insertOne(content) {
|
|
161
|
+
errors.assertArgCount(arguments, 1, 1);
|
|
162
|
+
content = nodbUtil.verifySodaDoc(content);
|
|
163
|
+
const options = {autoCommit: settings.autoCommit};
|
|
164
|
+
await this._impl.insertOne(content, options);
|
|
128
165
|
}
|
|
129
166
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
//-----------------------------------------------------------------------------
|
|
149
|
-
async function dropIndex(indexName, a2) {
|
|
150
|
-
let options = {};
|
|
151
|
-
|
|
152
|
-
nodbUtil.checkArgCount(arguments, 1, 2);
|
|
153
|
-
nodbUtil.assert(typeof indexName === 'string', 'NJS-005', 1);
|
|
154
|
-
if (arguments.length == 2) {
|
|
155
|
-
nodbUtil.assert(typeof a2 === 'object', 'NJS-005', 2);
|
|
156
|
-
options = a2;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
return await this._dropIndex(indexName, options);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
//-----------------------------------------------------------------------------
|
|
164
|
-
// getDataGuide()
|
|
165
|
-
// Return the data guide for the collection.
|
|
166
|
-
//-----------------------------------------------------------------------------
|
|
167
|
-
async function getDataGuide() {
|
|
168
|
-
nodbUtil.checkArgCount(arguments, 0, 0);
|
|
169
|
-
return await this._getDataGuide();
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
//-----------------------------------------------------------------------------
|
|
174
|
-
// save()
|
|
175
|
-
// Saves a single document into the collection.
|
|
176
|
-
//-----------------------------------------------------------------------------
|
|
177
|
-
async function save(content) {
|
|
178
|
-
nodbUtil.checkArgCount(arguments, 1, 1);
|
|
179
|
-
nodbUtil.assert(nodbUtil.isObject(content) ||
|
|
180
|
-
nodbUtil.isSodaDocument(content), 'NJS-005', 1);
|
|
167
|
+
//---------------------------------------------------------------------------
|
|
168
|
+
// insertOneAndGet()
|
|
169
|
+
//
|
|
170
|
+
// Inserts a single document into the collection and returns a result
|
|
171
|
+
// document containing metadata.
|
|
172
|
+
//---------------------------------------------------------------------------
|
|
173
|
+
async insertOneAndGet(content, a2) {
|
|
174
|
+
const options = {autoCommit: settings.autoCommit};
|
|
175
|
+
|
|
176
|
+
errors.assertArgCount(arguments, 1, 2);
|
|
177
|
+
content = nodbUtil.verifySodaDoc(content);
|
|
178
|
+
if (arguments.length == 2) {
|
|
179
|
+
errors.assertParamValue(nodbUtil.isObject(a2), 2);
|
|
180
|
+
if (a2.hint !== undefined) {
|
|
181
|
+
errors.assertParamPropValue(typeof a2.hint === 'string', 2, "hint");
|
|
182
|
+
options.hint = a2.hint;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
181
185
|
|
|
182
|
-
|
|
183
|
-
|
|
186
|
+
const doc = new SodaDocument();
|
|
187
|
+
doc._impl = await this._impl.insertOneAndGet(content, options);
|
|
188
|
+
return doc;
|
|
184
189
|
}
|
|
185
190
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
// document containing metadata.
|
|
194
|
-
//-----------------------------------------------------------------------------
|
|
195
|
-
async function saveAndGet(content, a2) {
|
|
196
|
-
let options = {};
|
|
197
|
-
|
|
198
|
-
nodbUtil.checkArgCount(arguments, 1, 2);
|
|
199
|
-
nodbUtil.assert(nodbUtil.isObject(content) ||
|
|
200
|
-
nodbUtil.isSodaDocument(content), 'NJS-005', 1);
|
|
201
|
-
|
|
202
|
-
if (arguments.length == 2) {
|
|
203
|
-
nodbUtil.assert(nodbUtil.isObject(a2), 'NJS-005', 2);
|
|
204
|
-
options = a2;
|
|
191
|
+
//---------------------------------------------------------------------------
|
|
192
|
+
// metaData()
|
|
193
|
+
//
|
|
194
|
+
// Property for the metadata associated with the collection.
|
|
195
|
+
//---------------------------------------------------------------------------
|
|
196
|
+
get metaData() {
|
|
197
|
+
return JSON.parse(this._impl.getMetaData());
|
|
205
198
|
}
|
|
206
199
|
|
|
207
|
-
|
|
208
|
-
|
|
200
|
+
//---------------------------------------------------------------------------
|
|
201
|
+
// name()
|
|
202
|
+
//
|
|
203
|
+
// Property for the name of the collection.
|
|
204
|
+
//---------------------------------------------------------------------------
|
|
205
|
+
get name() {
|
|
206
|
+
return this._impl.getName();
|
|
209
207
|
}
|
|
210
208
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
await this._truncate();
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
class SodaCollection {
|
|
226
|
-
|
|
227
|
-
_extend() {
|
|
228
|
-
this.createIndex = nodbUtil.callbackify(nodbUtil.serialize(createIndex));
|
|
229
|
-
this.drop = nodbUtil.callbackify(nodbUtil.serialize(drop));
|
|
230
|
-
this.dropIndex = nodbUtil.callbackify(nodbUtil.serialize(dropIndex));
|
|
231
|
-
this.getDataGuide = nodbUtil.callbackify(nodbUtil.serialize(getDataGuide));
|
|
232
|
-
this.insertMany = nodbUtil.callbackify(nodbUtil.serialize(insertMany));
|
|
233
|
-
this.insertManyAndGet = nodbUtil.callbackify(nodbUtil.serialize(insertManyAndGet));
|
|
234
|
-
this.insertOne = nodbUtil.callbackify(nodbUtil.serialize(insertOne));
|
|
235
|
-
this.insertOneAndGet = nodbUtil.callbackify(nodbUtil.serialize(insertOneAndGet));
|
|
236
|
-
this.save = nodbUtil.callbackify(nodbUtil.serialize(save));
|
|
237
|
-
this.saveAndGet = nodbUtil.callbackify(nodbUtil.serialize(saveAndGet));
|
|
238
|
-
this.truncate = nodbUtil.callbackify(nodbUtil.serialize(truncate));
|
|
209
|
+
//---------------------------------------------------------------------------
|
|
210
|
+
// save()
|
|
211
|
+
//
|
|
212
|
+
// Saves a single document into the collection.
|
|
213
|
+
//---------------------------------------------------------------------------
|
|
214
|
+
async save(content) {
|
|
215
|
+
errors.assertArgCount(arguments, 1, 1);
|
|
216
|
+
content = nodbUtil.verifySodaDoc(content);
|
|
217
|
+
const options = {autoCommit: settings.autoCommit};
|
|
218
|
+
await this._impl.save(content, options);
|
|
239
219
|
}
|
|
240
220
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
221
|
+
//---------------------------------------------------------------------------
|
|
222
|
+
// saveAndGet()
|
|
223
|
+
//
|
|
224
|
+
// Saves a single document into the collection and returns a result document
|
|
225
|
+
// containing metadata.
|
|
226
|
+
//---------------------------------------------------------------------------
|
|
227
|
+
async saveAndGet(content, a2) {
|
|
228
|
+
errors.assertArgCount(arguments, 1, 2);
|
|
229
|
+
content = nodbUtil.verifySodaDoc(content);
|
|
230
|
+
const options = {autoCommit: settings.autoCommit};
|
|
231
|
+
if (arguments.length == 2) {
|
|
232
|
+
errors.assertParamValue(nodbUtil.isObject(a2), 2);
|
|
233
|
+
if (a2.hint !== undefined) {
|
|
234
|
+
errors.assertParamPropValue(typeof a2.hint === 'string', 2, "hint");
|
|
235
|
+
options.hint = a2.hint;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
244
238
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
return
|
|
239
|
+
const doc = new SodaDocument();
|
|
240
|
+
doc._impl = await this._impl.saveAndGet(content, options);
|
|
241
|
+
return doc;
|
|
248
242
|
}
|
|
249
243
|
|
|
250
|
-
|
|
251
|
-
|
|
244
|
+
//---------------------------------------------------------------------------
|
|
245
|
+
// truncate()
|
|
246
|
+
//
|
|
247
|
+
// Remove all of the documents from a collection.
|
|
248
|
+
//---------------------------------------------------------------------------
|
|
249
|
+
async truncate() {
|
|
250
|
+
errors.assertArgCount(arguments, 0, 0);
|
|
251
|
+
await this._impl.truncate();
|
|
252
252
|
}
|
|
253
253
|
|
|
254
254
|
}
|
|
255
255
|
|
|
256
|
+
nodbUtil.wrapFns(SodaCollection.prototype,
|
|
257
|
+
"createIndex",
|
|
258
|
+
"drop",
|
|
259
|
+
"dropIndex",
|
|
260
|
+
"getDataGuide",
|
|
261
|
+
"insertMany",
|
|
262
|
+
"insertManyAndGet",
|
|
263
|
+
"insertOne",
|
|
264
|
+
"insertOneAndGet",
|
|
265
|
+
"save",
|
|
266
|
+
"saveAndGet",
|
|
267
|
+
"truncate");
|
|
268
|
+
|
|
256
269
|
module.exports = SodaCollection;
|