oracledb 3.0.0 → 3.1.2
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 +135 -8
- package/README.md +6 -4
- package/build/Release/oracledb-abi48-darwin-x64.node +0 -0
- package/build/Release/oracledb-abi48-darwin-x64.node-buildinfo.txt +1 -0
- package/build/Release/oracledb-abi48-linux-x64.node +0 -0
- package/build/Release/oracledb-abi48-linux-x64.node-buildinfo.txt +1 -0
- package/build/Release/oracledb-abi48-win32-x64.node +0 -0
- package/build/Release/oracledb-abi48-win32-x64.node-buildinfo.txt +1 -0
- package/build/Release/oracledb-abi57-darwin-x64.node +0 -0
- package/build/Release/oracledb-abi57-darwin-x64.node-buildinfo.txt +1 -0
- package/build/Release/oracledb-abi57-linux-x64.node +0 -0
- package/build/Release/oracledb-abi57-linux-x64.node-buildinfo.txt +1 -0
- package/build/Release/oracledb-abi57-win32-x64.node +0 -0
- package/build/Release/oracledb-abi57-win32-x64.node-buildinfo.txt +1 -0
- package/build/Release/oracledb-abi64-darwin-x64.node +0 -0
- package/build/Release/oracledb-abi64-darwin-x64.node-buildinfo.txt +1 -0
- package/build/Release/oracledb-abi64-linux-x64.node +0 -0
- package/build/Release/oracledb-abi64-linux-x64.node-buildinfo.txt +1 -0
- package/build/Release/oracledb-abi64-win32-x64.node +0 -0
- package/build/Release/oracledb-abi64-win32-x64.node-buildinfo.txt +1 -0
- package/build/Release/oracledb-abi67-darwin-x64.node +0 -0
- package/build/Release/oracledb-abi67-darwin-x64.node-buildinfo.txt +1 -0
- package/build/Release/oracledb-abi67-linux-x64.node +0 -0
- package/build/Release/oracledb-abi67-linux-x64.node-buildinfo.txt +1 -0
- package/build/Release/oracledb-abi67-win32-x64.node +0 -0
- package/build/Release/oracledb-abi67-win32-x64.node-buildinfo.txt +1 -0
- package/lib/connection.js +18 -4
- package/lib/oracledb.js +44 -92
- package/lib/pool.js +36 -2
- package/lib/sodaCollection.js +1 -1
- package/lib/sodaDatabase.js +1 -1
- package/lib/util.js +82 -5
- package/package/README.md +32 -101
- package/package/install.js +139 -0
- package/package/prunebinaries.js +51 -0
- package/package.json +4 -11
- package/binding.gyp +0 -162
- package/lib/rel.txt +0 -1
- package/odpi/.npmignore +0 -4
- package/odpi/LICENSE.md +0 -218
- package/odpi/README.md +0 -61
- package/odpi/embed/README.md +0 -4
- package/odpi/embed/dpi.c +0 -50
- package/odpi/include/dpi.h +0 -1748
- package/odpi/src/dpiConn.c +0 -2089
- package/odpi/src/dpiContext.c +0 -296
- package/odpi/src/dpiData.c +0 -797
- package/odpi/src/dpiDebug.c +0 -184
- package/odpi/src/dpiDeqOptions.c +0 -370
- package/odpi/src/dpiEnqOptions.c +0 -174
- package/odpi/src/dpiEnv.c +0 -189
- package/odpi/src/dpiError.c +0 -204
- package/odpi/src/dpiErrorMessages.h +0 -86
- package/odpi/src/dpiGen.c +0 -303
- package/odpi/src/dpiGlobal.c +0 -292
- package/odpi/src/dpiHandleList.c +0 -117
- package/odpi/src/dpiHandlePool.c +0 -118
- package/odpi/src/dpiImpl.h +0 -1707
- package/odpi/src/dpiLob.c +0 -506
- package/odpi/src/dpiMsgProps.c +0 -386
- package/odpi/src/dpiObject.c +0 -897
- package/odpi/src/dpiObjectAttr.c +0 -115
- package/odpi/src/dpiObjectType.c +0 -326
- package/odpi/src/dpiOci.c +0 -3527
- package/odpi/src/dpiOracleType.c +0 -492
- package/odpi/src/dpiPool.c +0 -549
- package/odpi/src/dpiRowid.c +0 -136
- package/odpi/src/dpiSodaColl.c +0 -685
- package/odpi/src/dpiSodaCollCursor.c +0 -143
- package/odpi/src/dpiSodaDb.c +0 -432
- package/odpi/src/dpiSodaDoc.c +0 -230
- package/odpi/src/dpiSodaDocCursor.c +0 -143
- package/odpi/src/dpiStmt.c +0 -1797
- package/odpi/src/dpiSubscr.c +0 -674
- package/odpi/src/dpiUtils.c +0 -410
- package/odpi/src/dpiVar.c +0 -1794
- package/package/MAKEPKG.BAT +0 -156
- package/package/Makefile +0 -85
- package/package/createpackage.js +0 -186
- package/package/extractpackage.js +0 -76
- package/package/getversion.js +0 -37
- package/package/oracledbinstall.js +0 -497
- package/package/package.json +0 -54
- package/package/util.js +0 -286
- package/src/njsCommon.cpp +0 -1055
- package/src/njsCommon.h +0 -484
- package/src/njsConnection.cpp +0 -2926
- package/src/njsConnection.h +0 -227
- package/src/njsIntLob.cpp +0 -618
- package/src/njsIntLob.h +0 -179
- package/src/njsMessages.cpp +0 -122
- package/src/njsMessages.h +0 -118
- package/src/njsOracle.cpp +0 -1274
- package/src/njsOracle.h +0 -237
- package/src/njsPool.cpp +0 -482
- package/src/njsPool.h +0 -132
- package/src/njsResultSet.cpp +0 -478
- package/src/njsResultSet.h +0 -120
- package/src/njsSodaCollection.cpp +0 -507
- package/src/njsSodaCollection.h +0 -128
- package/src/njsSodaDatabase.cpp +0 -335
- package/src/njsSodaDatabase.h +0 -108
- package/src/njsSodaDocCursor.cpp +0 -203
- package/src/njsSodaDocCursor.h +0 -94
- package/src/njsSodaDocument.cpp +0 -412
- package/src/njsSodaDocument.h +0 -105
- package/src/njsSodaOperation.cpp +0 -557
- package/src/njsSodaOperation.h +0 -123
- package/src/njsSubscription.cpp +0 -388
- package/src/njsSubscription.h +0 -111
- package/src/njsUtils.cpp +0 -158
- package/src/njsUtils.h +0 -68
package/src/njsSodaDatabase.cpp
DELETED
|
@@ -1,335 +0,0 @@
|
|
|
1
|
-
/* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. */
|
|
2
|
-
|
|
3
|
-
/******************************************************************************
|
|
4
|
-
*
|
|
5
|
-
* You may not use the identified files except in compliance with the Apache
|
|
6
|
-
* License, Version 2.0 (the "License.")
|
|
7
|
-
*
|
|
8
|
-
* You may obtain a copy of the License at
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0.
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
13
|
-
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
*
|
|
15
|
-
* See the License for the specific language governing permissions and
|
|
16
|
-
* limitations under the License.
|
|
17
|
-
*
|
|
18
|
-
* This file uses NAN:
|
|
19
|
-
*
|
|
20
|
-
* Copyright (c) 2015 NAN contributors
|
|
21
|
-
*
|
|
22
|
-
* NAN contributors listed at https://github.com/rvagg/nan#contributors
|
|
23
|
-
*
|
|
24
|
-
* Permission is hereby granted, free of charge, to any person obtaining
|
|
25
|
-
* a copy of this software and associated documentation files (the
|
|
26
|
-
* "Software"), to deal in the Software without restriction, including
|
|
27
|
-
* without limitation the rights to use, copy, modify, merge, publish,
|
|
28
|
-
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
29
|
-
* permit persons to whom the Software is furnished to do so, subject to
|
|
30
|
-
* the following conditions:
|
|
31
|
-
*
|
|
32
|
-
* The above copyright notice and this permission notice shall be
|
|
33
|
-
* included in all copies or substantial portions of the Software.
|
|
34
|
-
*
|
|
35
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
36
|
-
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
37
|
-
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
38
|
-
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
39
|
-
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
40
|
-
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
41
|
-
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
42
|
-
*
|
|
43
|
-
* NAME
|
|
44
|
-
* njsSodaDatabase.cpp
|
|
45
|
-
*
|
|
46
|
-
* DESCRIPTION
|
|
47
|
-
* SodaDatabase class implementation.
|
|
48
|
-
*
|
|
49
|
-
****************************************************************************/
|
|
50
|
-
|
|
51
|
-
#include "njsSodaDatabase.h"
|
|
52
|
-
#include "njsConnection.h"
|
|
53
|
-
#include "njsSodaCollection.h"
|
|
54
|
-
#include "njsSodaDocument.h"
|
|
55
|
-
#include "njsUtils.h"
|
|
56
|
-
|
|
57
|
-
#include <iostream>
|
|
58
|
-
|
|
59
|
-
using namespace std;
|
|
60
|
-
|
|
61
|
-
// Persistent sodaDB class handle
|
|
62
|
-
Nan::Persistent<FunctionTemplate> njsSodaDatabase::sodaDBTemplate_s;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
//-----------------------------------------------------------------------------
|
|
66
|
-
// njsSodaDatabase::Init()
|
|
67
|
-
// Initialization function of SodaDatabase class. Maps functions and
|
|
68
|
-
// properties from JS to C++.
|
|
69
|
-
//-----------------------------------------------------------------------------
|
|
70
|
-
void njsSodaDatabase::Init(Local<Object> target)
|
|
71
|
-
{
|
|
72
|
-
Nan::HandleScope scope;
|
|
73
|
-
Local<FunctionTemplate> tpl = Nan::New<FunctionTemplate>(New);
|
|
74
|
-
|
|
75
|
-
tpl->InstanceTemplate()->SetInternalFieldCount(1);
|
|
76
|
-
tpl->SetClassName(Nan::New<v8::String>("SodaDatabase").ToLocalChecked());
|
|
77
|
-
|
|
78
|
-
Nan::SetPrototypeMethod(tpl, "createCollection", CreateCollection);
|
|
79
|
-
Nan::SetPrototypeMethod(tpl, "openCollection", OpenCollection);
|
|
80
|
-
Nan::SetPrototypeMethod(tpl, "getCollectionNames", GetCollectionNames);
|
|
81
|
-
Nan::SetPrototypeMethod(tpl, "createDocument", CreateDocument);
|
|
82
|
-
|
|
83
|
-
sodaDBTemplate_s.Reset(tpl);
|
|
84
|
-
Nan::Set(target, Nan::New<v8::String>("SodaDB").ToLocalChecked(),
|
|
85
|
-
tpl->GetFunction());
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
//-----------------------------------------------------------------------------
|
|
90
|
-
// njsSodaDatabase::New()
|
|
91
|
-
// To create a new instance of njsSodaDatabase object
|
|
92
|
-
//-----------------------------------------------------------------------------
|
|
93
|
-
NAN_METHOD(njsSodaDatabase::New)
|
|
94
|
-
{
|
|
95
|
-
njsSodaDatabase *sodaDB = new njsSodaDatabase();
|
|
96
|
-
sodaDB->Wrap(info.Holder());
|
|
97
|
-
info.GetReturnValue().Set(info.Holder());
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
//-----------------------------------------------------------------------------
|
|
102
|
-
// njsSodaDatabase::CreateFromHandle()
|
|
103
|
-
// Create a new sodaDatabase from baton.
|
|
104
|
-
//-----------------------------------------------------------------------------
|
|
105
|
-
Local<Object> njsSodaDatabase::CreateFromHandle(Local<Object> jsOracledb,
|
|
106
|
-
dpiSodaDb *dbHandle)
|
|
107
|
-
{
|
|
108
|
-
Nan::EscapableHandleScope scope;
|
|
109
|
-
Local<Function> func;
|
|
110
|
-
Local<Object> obj;
|
|
111
|
-
njsSodaDatabase *db;
|
|
112
|
-
|
|
113
|
-
func = Nan::GetFunction(
|
|
114
|
-
Nan::New<FunctionTemplate>(sodaDBTemplate_s)).ToLocalChecked();
|
|
115
|
-
obj = Nan::NewInstance(func).ToLocalChecked();
|
|
116
|
-
db = Nan::ObjectWrap::Unwrap<njsSodaDatabase>(obj);
|
|
117
|
-
db->dpiSodaDbHandle = dbHandle;
|
|
118
|
-
db->jsOracledb.Reset(jsOracledb);
|
|
119
|
-
|
|
120
|
-
return scope.Escape(obj);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
//-----------------------------------------------------------------------------
|
|
125
|
-
// njsSodaDatabase::CreateCollection()
|
|
126
|
-
// To create a new SODA Collection object.
|
|
127
|
-
//-----------------------------------------------------------------------------
|
|
128
|
-
NAN_METHOD(njsSodaDatabase::CreateCollection)
|
|
129
|
-
{
|
|
130
|
-
njsBaton *baton;
|
|
131
|
-
|
|
132
|
-
njsSodaDatabase *db = (njsSodaDatabase*) ValidateArgs(info, 3, 3);
|
|
133
|
-
if (!db)
|
|
134
|
-
return;
|
|
135
|
-
|
|
136
|
-
baton = db->CreateBaton(info);
|
|
137
|
-
if (!baton)
|
|
138
|
-
return;
|
|
139
|
-
|
|
140
|
-
baton->SetDPISodaDbHandle(db->dpiSodaDbHandle);
|
|
141
|
-
baton->jsOracledb.Reset(db->jsOracledb);
|
|
142
|
-
|
|
143
|
-
Local <Object> sodaProps;
|
|
144
|
-
db->GetStringArg(info, 0, baton->sodaCollName);
|
|
145
|
-
if (db->GetObjectArg(info, 1, sodaProps)) {
|
|
146
|
-
baton->GetStringFromJSON(sodaProps, "metaData", 0,baton->sodaMetaData);
|
|
147
|
-
baton->GetUnsignedIntFromJSON(sodaProps, "mode", 0,
|
|
148
|
-
&baton->createCollectionMode);
|
|
149
|
-
}
|
|
150
|
-
baton->autoCommit = baton->GetOracledb()->getAutoCommit();
|
|
151
|
-
baton->QueueWork("CreateCollection", Async_CreateCollection,
|
|
152
|
-
Async_AfterCreateCollection, 2);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
//-----------------------------------------------------------------------------
|
|
157
|
-
// njsSodaDatabase::Async_CreateCollection()
|
|
158
|
-
// Worker thread function to create SODA collection object
|
|
159
|
-
//-----------------------------------------------------------------------------
|
|
160
|
-
void njsSodaDatabase::Async_CreateCollection(njsBaton *baton)
|
|
161
|
-
{
|
|
162
|
-
uint32_t flags = DPI_SODA_FLAGS_DEFAULT;
|
|
163
|
-
|
|
164
|
-
if (baton->autoCommit)
|
|
165
|
-
flags |= DPI_SODA_FLAGS_ATOMIC_COMMIT;
|
|
166
|
-
if (baton->createCollectionMode == NJS_SODA_COLL_CREATE_MODE_MAP)
|
|
167
|
-
flags |= DPI_SODA_FLAGS_CREATE_COLL_MAP;
|
|
168
|
-
|
|
169
|
-
if (dpiSodaDb_createCollection (baton->dpiSodaDbHandle,
|
|
170
|
-
baton->sodaCollName.c_str(), baton->sodaCollName.length(),
|
|
171
|
-
baton->sodaMetaData.c_str(), baton->sodaMetaData.length(), flags,
|
|
172
|
-
&baton->dpiSodaCollHandle) < 0) {
|
|
173
|
-
baton->GetDPIError();
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
//-----------------------------------------------------------------------------
|
|
180
|
-
// njsSodaDatabase::Async_AfterCreateCollection()
|
|
181
|
-
// Package and return the created SODA-collection object to JS land.
|
|
182
|
-
//-----------------------------------------------------------------------------
|
|
183
|
-
void njsSodaDatabase::Async_AfterCreateCollection(njsBaton *baton,
|
|
184
|
-
Local<Value> argv[])
|
|
185
|
-
{
|
|
186
|
-
argv[1] = njsSodaCollection::CreateFromBaton(baton);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
//-----------------------------------------------------------------------------
|
|
191
|
-
// njsSodaDatabase::OpenCollection()
|
|
192
|
-
// Open an existing soda collection
|
|
193
|
-
//-----------------------------------------------------------------------------
|
|
194
|
-
NAN_METHOD(njsSodaDatabase::OpenCollection)
|
|
195
|
-
{
|
|
196
|
-
njsSodaDatabase *db = (njsSodaDatabase*) ValidateArgs(info, 2, 2);
|
|
197
|
-
if (!db)
|
|
198
|
-
return;
|
|
199
|
-
|
|
200
|
-
njsBaton *baton = db->CreateBaton(info);
|
|
201
|
-
if (!baton)
|
|
202
|
-
return ;
|
|
203
|
-
|
|
204
|
-
baton->SetDPISodaDbHandle(db->dpiSodaDbHandle);
|
|
205
|
-
baton->jsOracledb.Reset(db->jsOracledb);
|
|
206
|
-
db->GetStringArg(info, 0, baton->sodaCollName);
|
|
207
|
-
baton->autoCommit = baton->GetOracledb()->getAutoCommit();
|
|
208
|
-
baton->QueueWork("OpenCollection", Async_OpenCollection,
|
|
209
|
-
Async_AfterOpenCollection, 2);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
//-----------------------------------------------------------------------------
|
|
214
|
-
// njsSodaDatabase::Async_OpenCollection()
|
|
215
|
-
// Worker thread function to open an existing SODA collection
|
|
216
|
-
//-----------------------------------------------------------------------------
|
|
217
|
-
void njsSodaDatabase::Async_OpenCollection(njsBaton *baton)
|
|
218
|
-
{
|
|
219
|
-
uint32_t flags = DPI_SODA_FLAGS_DEFAULT;
|
|
220
|
-
|
|
221
|
-
if (baton->autoCommit)
|
|
222
|
-
flags |= DPI_SODA_FLAGS_ATOMIC_COMMIT;
|
|
223
|
-
if (dpiSodaDb_openCollection(baton->dpiSodaDbHandle,
|
|
224
|
-
baton->sodaCollName.c_str(), baton->sodaCollName.length(), flags,
|
|
225
|
-
&baton->dpiSodaCollHandle) < 0)
|
|
226
|
-
baton->GetDPIError();
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
//-----------------------------------------------------------------------------
|
|
231
|
-
// njsSodaDatabase::Async_AfterOpenCollection()
|
|
232
|
-
// Returns opened SODA collection to JS land
|
|
233
|
-
//-----------------------------------------------------------------------------
|
|
234
|
-
void njsSodaDatabase::Async_AfterOpenCollection(njsBaton *baton,
|
|
235
|
-
Local<Value> argv[])
|
|
236
|
-
{
|
|
237
|
-
if (baton->dpiSodaCollHandle)
|
|
238
|
-
argv[1] = njsSodaCollection::CreateFromBaton(baton);
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
//-----------------------------------------------------------------------------
|
|
243
|
-
// njsSodaDatabase::GetCollectionNames()
|
|
244
|
-
// Returns an array of collection names
|
|
245
|
-
//-----------------------------------------------------------------------------
|
|
246
|
-
NAN_METHOD(njsSodaDatabase::GetCollectionNames)
|
|
247
|
-
{
|
|
248
|
-
njsBaton *baton = NULL;
|
|
249
|
-
njsSodaDatabase *db = (njsSodaDatabase*) ValidateArgs(info, 2, 2);
|
|
250
|
-
if (!db)
|
|
251
|
-
return;
|
|
252
|
-
|
|
253
|
-
baton = db->CreateBaton(info);
|
|
254
|
-
if (!baton)
|
|
255
|
-
return;
|
|
256
|
-
|
|
257
|
-
Local<Object> opts;
|
|
258
|
-
baton->SetDPISodaDbHandle(db->dpiSodaDbHandle);
|
|
259
|
-
if (db->GetObjectArg(info, 0, opts)) {
|
|
260
|
-
baton->GetIntFromJSON(opts, "limit", 1, &baton->limit);
|
|
261
|
-
baton->GetStringFromJSON(opts, "startsWith", 1, baton->startsWith);
|
|
262
|
-
}
|
|
263
|
-
baton->QueueWork("GetCollectionNames", Async_GetCollectionNames,
|
|
264
|
-
Async_AfterGetCollectionNames, 2);
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
//-----------------------------------------------------------------------------
|
|
269
|
-
// njsSodaDatabase::AsyncGetCollectionNames()
|
|
270
|
-
// Worker thread function to get an array of collection names.
|
|
271
|
-
//-----------------------------------------------------------------------------
|
|
272
|
-
void njsSodaDatabase::Async_GetCollectionNames(njsBaton *baton)
|
|
273
|
-
{
|
|
274
|
-
baton->sodaCollNames = new dpiSodaCollNames();
|
|
275
|
-
if (dpiSodaDb_getCollectionNames(baton->dpiSodaDbHandle,
|
|
276
|
-
baton->startsWith.c_str(), baton->startsWith.length(),
|
|
277
|
-
(uint32_t) baton->limit, DPI_SODA_FLAGS_DEFAULT,
|
|
278
|
-
baton->sodaCollNames) < 0)
|
|
279
|
-
baton->GetDPIError();
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
//-----------------------------------------------------------------------------
|
|
284
|
-
// njsSodaDatabase::Async_AfterGetCollectionNames()
|
|
285
|
-
// Returns an array of collection names on success
|
|
286
|
-
//-----------------------------------------------------------------------------
|
|
287
|
-
void njsSodaDatabase::Async_AfterGetCollectionNames(njsBaton* baton,
|
|
288
|
-
Local<Value> argv[])
|
|
289
|
-
{
|
|
290
|
-
Nan::EscapableHandleScope scope;
|
|
291
|
-
|
|
292
|
-
dpiSodaCollNames *names = baton->sodaCollNames;
|
|
293
|
-
Local<Array> arrayVal = Nan::New<Array>(names->numNames);
|
|
294
|
-
for (uint32_t coll = 0; coll < names->numNames; coll++) {
|
|
295
|
-
Local<String> name = Nan::New<String>(names->names[coll],
|
|
296
|
-
names->nameLengths[coll]).ToLocalChecked();
|
|
297
|
-
Nan::Set(arrayVal, coll, name);
|
|
298
|
-
}
|
|
299
|
-
argv[1] = scope.Escape(arrayVal);
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
//-----------------------------------------------------------------------------
|
|
304
|
-
// njsSodaDatabase::CreateDocument()
|
|
305
|
-
// To create a SODA document object with the given content and atttributes.
|
|
306
|
-
//-----------------------------------------------------------------------------
|
|
307
|
-
NAN_METHOD(njsSodaDatabase::CreateDocument)
|
|
308
|
-
{
|
|
309
|
-
njsSodaDatabase *db = (njsSodaDatabase*) ValidateArgs(info, 2, 2);
|
|
310
|
-
if (!db)
|
|
311
|
-
return;
|
|
312
|
-
|
|
313
|
-
// get options
|
|
314
|
-
Local<Object> options;
|
|
315
|
-
std::string key, mediaType, error;
|
|
316
|
-
if (db->GetObjectArg(info, 1, options)) {
|
|
317
|
-
njsUtils::GetStringFromJSON(options, "key", 1, key, error);
|
|
318
|
-
njsUtils::GetStringFromJSON(options, "mediaType", 1, mediaType, error);
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
// create ODPI-C document
|
|
322
|
-
dpiSodaDoc *doc;
|
|
323
|
-
Local<Value> content = info[0].As<Value>();
|
|
324
|
-
if (dpiSodaDb_createDocument(db->dpiSodaDbHandle, key.c_str(),
|
|
325
|
-
key.length(),
|
|
326
|
-
Buffer::Data(content), Buffer::Length(content), mediaType.c_str(),
|
|
327
|
-
mediaType.length(), (uint32_t) DPI_SODA_FLAGS_DEFAULT, &doc) < 0) {
|
|
328
|
-
njsOracledb::ThrowDPIError();
|
|
329
|
-
return;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
// return wrapped ODPI-C document
|
|
333
|
-
Local<Object> obj = njsSodaDocument::CreateFromDPIDoc(doc);
|
|
334
|
-
info.GetReturnValue().Set(obj);
|
|
335
|
-
}
|
package/src/njsSodaDatabase.h
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
/* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. */
|
|
2
|
-
|
|
3
|
-
/*****************************************************************************
|
|
4
|
-
*
|
|
5
|
-
* You may not use the identified files except in compliance with the Apache
|
|
6
|
-
* License, Version 2.0 (the "License.")
|
|
7
|
-
*
|
|
8
|
-
* You may obtain a copy of the License at
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0.
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
13
|
-
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
*
|
|
15
|
-
* See the License for the specific language governing permissions and
|
|
16
|
-
* limitations under the License.
|
|
17
|
-
*
|
|
18
|
-
* This file uses NAN:
|
|
19
|
-
*
|
|
20
|
-
* Copyright (c) 2015 NAN contributors
|
|
21
|
-
*
|
|
22
|
-
* NAN contributors listed at https://github.com/rvagg/nan#contributors
|
|
23
|
-
*
|
|
24
|
-
* Permission is hereby granted, free of charge, to any person obtaining
|
|
25
|
-
* a copy of this software and associated documentation files (the
|
|
26
|
-
* "Software"), to deal in the Software without restriction, including
|
|
27
|
-
* without limitation the rights to use, copy, modify, merge, publish,
|
|
28
|
-
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
29
|
-
* permit persons to whom the Software is furnished to do so, subject to
|
|
30
|
-
* the following conditions:
|
|
31
|
-
*
|
|
32
|
-
* The above copyright notice and this permission notice shall be
|
|
33
|
-
* included in all copies or substantial portions of the Software.
|
|
34
|
-
*
|
|
35
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
36
|
-
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
37
|
-
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
38
|
-
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
39
|
-
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
40
|
-
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
41
|
-
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
42
|
-
*
|
|
43
|
-
* NAME
|
|
44
|
-
* njsSodaDatabase.h
|
|
45
|
-
*
|
|
46
|
-
* DESCRIPTION
|
|
47
|
-
* SodaDatabase class
|
|
48
|
-
*
|
|
49
|
-
*****************************************************************************/
|
|
50
|
-
|
|
51
|
-
#ifndef __NJSSODADB_H__
|
|
52
|
-
#define __NJSSODADB_H__
|
|
53
|
-
|
|
54
|
-
#include "njsCommon.h"
|
|
55
|
-
|
|
56
|
-
//-----------------------------------------------------------------------------
|
|
57
|
-
// njsSodaDatabase
|
|
58
|
-
// Pseudo top level object for all SODA related functionalities.
|
|
59
|
-
//-----------------------------------------------------------------------------
|
|
60
|
-
class njsSodaDatabase : public njsCommon {
|
|
61
|
-
public:
|
|
62
|
-
static void Init(Local<Object> target);
|
|
63
|
-
static Local<Object> CreateFromHandle(Local<Object> jsOracledb,
|
|
64
|
-
dpiSodaDb *dbHandle);
|
|
65
|
-
|
|
66
|
-
private:
|
|
67
|
-
static NAN_METHOD(New);
|
|
68
|
-
|
|
69
|
-
static NAN_METHOD(CreateCollection);
|
|
70
|
-
static void Async_CreateCollection(njsBaton *baton);
|
|
71
|
-
static void Async_AfterCreateCollection(njsBaton *baton,
|
|
72
|
-
Local<Value> argv[]);
|
|
73
|
-
|
|
74
|
-
static NAN_METHOD(OpenCollection);
|
|
75
|
-
static void Async_OpenCollection(njsBaton *baton);
|
|
76
|
-
static void Async_AfterOpenCollection(njsBaton *baton,
|
|
77
|
-
Local<Value> argv[]);
|
|
78
|
-
|
|
79
|
-
static NAN_METHOD(GetCollectionNames);
|
|
80
|
-
static void Async_GetCollectionNames(njsBaton *baton);
|
|
81
|
-
static void Async_AfterGetCollectionNames(njsBaton *baton,
|
|
82
|
-
Local<Value> argv[]);
|
|
83
|
-
|
|
84
|
-
static NAN_METHOD(CreateDocument);
|
|
85
|
-
|
|
86
|
-
bool IsValid() const { return ( true ); } // sodaDB never closes.
|
|
87
|
-
njsErrorType GetInvalidErrorType() const { return errSuccess; }
|
|
88
|
-
|
|
89
|
-
// Constructor
|
|
90
|
-
njsSodaDatabase() : dpiSodaDbHandle(NULL) {}
|
|
91
|
-
|
|
92
|
-
// Destructor
|
|
93
|
-
~njsSodaDatabase () {
|
|
94
|
-
if (dpiSodaDbHandle) {
|
|
95
|
-
dpiSodaDb_release(dpiSodaDbHandle);
|
|
96
|
-
dpiSodaDbHandle = NULL;
|
|
97
|
-
}
|
|
98
|
-
jsOracledb.Reset();
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// Member variables
|
|
102
|
-
dpiSodaDb *dpiSodaDbHandle; // Top level SodaDB object
|
|
103
|
-
Nan::Persistent<Object> jsOracledb; // Oracledb object from JS land
|
|
104
|
-
|
|
105
|
-
static Nan::Persistent<FunctionTemplate> sodaDBTemplate_s; // template
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
#endif // __NJSSODADB_H__
|
package/src/njsSodaDocCursor.cpp
DELETED
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
/* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. */
|
|
2
|
-
|
|
3
|
-
/*************************************************************************
|
|
4
|
-
*
|
|
5
|
-
* You may not use the identified files except in compliance with the Apache
|
|
6
|
-
* License, Version 2.0 (the "License.")
|
|
7
|
-
*
|
|
8
|
-
* You may obtain a copy of the License at
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0.
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
13
|
-
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
*
|
|
15
|
-
* See the License for the specific language governing permissions and
|
|
16
|
-
* limitations under the License.
|
|
17
|
-
*
|
|
18
|
-
* This file uses NAN:
|
|
19
|
-
*
|
|
20
|
-
* Copyright (c) 2015 NAN contributors
|
|
21
|
-
*
|
|
22
|
-
* NAN contributors listed at https://github.com/rvagg/nan#contributors
|
|
23
|
-
*
|
|
24
|
-
* Permission is hereby granted, free of charge, to any person obtaining
|
|
25
|
-
* a copy of this software and associated documentation files (the
|
|
26
|
-
* "Software"), to deal in the Software without restriction, including
|
|
27
|
-
* without limitation the rights to use, copy, modify, merge, publish,
|
|
28
|
-
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
29
|
-
* permit persons to whom the Software is furnished to do so, subject to
|
|
30
|
-
* the following conditions:
|
|
31
|
-
*
|
|
32
|
-
* The above copyright notice and this permission notice shall be
|
|
33
|
-
* included in all copies or substantial portions of the Software.
|
|
34
|
-
*
|
|
35
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
36
|
-
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
37
|
-
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
38
|
-
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
39
|
-
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
40
|
-
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
41
|
-
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
42
|
-
*
|
|
43
|
-
* NAME
|
|
44
|
-
* njsSodaDocCursor.cpp
|
|
45
|
-
*
|
|
46
|
-
* DESCRIPTION
|
|
47
|
-
* Soda Document Cursor class implementation.
|
|
48
|
-
*
|
|
49
|
-
|
|
50
|
-
************************************************************************/
|
|
51
|
-
|
|
52
|
-
#include "njsOracle.h"
|
|
53
|
-
#include "njsSodaDocCursor.h"
|
|
54
|
-
#include "njsSodaDocument.h"
|
|
55
|
-
|
|
56
|
-
Nan::Persistent<FunctionTemplate> njsSodaDocCursor::sodaDocCursorTemplate_s;
|
|
57
|
-
|
|
58
|
-
//-----------------------------------------------------------------------------
|
|
59
|
-
// njsSodaDocCursor::Init()
|
|
60
|
-
// Initialization function, maps functions from JS to C++.
|
|
61
|
-
//-----------------------------------------------------------------------------
|
|
62
|
-
void njsSodaDocCursor::Init(Local<Object> target)
|
|
63
|
-
{
|
|
64
|
-
Nan::HandleScope scope;
|
|
65
|
-
Local<FunctionTemplate> tpl = Nan::New<FunctionTemplate>(New);
|
|
66
|
-
|
|
67
|
-
tpl->InstanceTemplate()->SetInternalFieldCount(1);
|
|
68
|
-
tpl->SetClassName(Nan::New<v8::String>("SodaDocCursor").ToLocalChecked());
|
|
69
|
-
|
|
70
|
-
// Methods
|
|
71
|
-
Nan::SetPrototypeMethod(tpl, "getNext", GetNext);
|
|
72
|
-
Nan::SetPrototypeMethod(tpl, "close", Close);
|
|
73
|
-
|
|
74
|
-
sodaDocCursorTemplate_s.Reset(tpl);
|
|
75
|
-
Nan::Set(target, Nan::New<v8::String>("SodaDocCursor").ToLocalChecked(),
|
|
76
|
-
tpl->GetFunction());
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
//-----------------------------------------------------------------------------
|
|
81
|
-
// njsSodaDocCursor::New
|
|
82
|
-
// Create new object accesible from JS. This is always called from within
|
|
83
|
-
// CreateFromBaton() and never from any external JS.
|
|
84
|
-
//-----------------------------------------------------------------------------
|
|
85
|
-
NAN_METHOD(njsSodaDocCursor::New)
|
|
86
|
-
{
|
|
87
|
-
njsSodaDocCursor *cursor = new njsSodaDocCursor();
|
|
88
|
-
cursor->Wrap(info.Holder());
|
|
89
|
-
info.GetReturnValue().Set(info.Holder());
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
//-----------------------------------------------------------------------------
|
|
94
|
-
// njsSodaDocCursor::CreateFromBaton()
|
|
95
|
-
// Creates a new SODA document cursor object and wraps it for use within
|
|
96
|
-
// Javascript. The ODPI-C cursor reference is transferred from the baton to the
|
|
97
|
-
// new object.
|
|
98
|
-
//-----------------------------------------------------------------------------
|
|
99
|
-
Local<Object> njsSodaDocCursor::CreateFromBaton(njsBaton *baton)
|
|
100
|
-
{
|
|
101
|
-
Nan::EscapableHandleScope scope;
|
|
102
|
-
njsSodaDocCursor *cursor;
|
|
103
|
-
Local<Function> func;
|
|
104
|
-
Local<Object> obj;
|
|
105
|
-
|
|
106
|
-
func = Nan::GetFunction(Nan::New<FunctionTemplate>(
|
|
107
|
-
sodaDocCursorTemplate_s)).ToLocalChecked();
|
|
108
|
-
obj = Nan::NewInstance(func).ToLocalChecked();
|
|
109
|
-
cursor = Nan::ObjectWrap::Unwrap<njsSodaDocCursor>(obj);
|
|
110
|
-
cursor->dpiSodaDocCursorHandle = baton->dpiSodaDocCursorHandle;
|
|
111
|
-
baton->dpiSodaDocCursorHandle = NULL;
|
|
112
|
-
cursor->jsOracledb.Reset(baton->jsOracledb);
|
|
113
|
-
|
|
114
|
-
return scope.Escape(obj);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
//-----------------------------------------------------------------------------
|
|
119
|
-
// njsSodaDocCursor::GetNext()
|
|
120
|
-
// Get the next SODA document from the cursor, if one is available.
|
|
121
|
-
//-----------------------------------------------------------------------------
|
|
122
|
-
NAN_METHOD(njsSodaDocCursor::GetNext)
|
|
123
|
-
{
|
|
124
|
-
njsSodaDocCursor *cursor = (njsSodaDocCursor*) ValidateArgs(info, 1, 1);
|
|
125
|
-
if (!cursor)
|
|
126
|
-
return;
|
|
127
|
-
|
|
128
|
-
njsBaton *baton = cursor->CreateBaton(info);
|
|
129
|
-
if (!baton)
|
|
130
|
-
return;
|
|
131
|
-
|
|
132
|
-
baton->SetDPISodaDocCursorHandle(cursor->dpiSodaDocCursorHandle);
|
|
133
|
-
baton->jsOracledb.Reset(cursor->jsOracledb);
|
|
134
|
-
baton->autoCommit = baton->GetOracledb()->getAutoCommit();
|
|
135
|
-
baton->QueueWork("GetNextDoc", Async_GetNext, Async_AfterGetNext, 2);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
//-----------------------------------------------------------------------------
|
|
140
|
-
// njsSodaDocCursor::Async_GetNext()
|
|
141
|
-
// Peform the work of obtaining the next SODA document from the cursor, if
|
|
142
|
-
// one is available.
|
|
143
|
-
//-----------------------------------------------------------------------------
|
|
144
|
-
void njsSodaDocCursor::Async_GetNext(njsBaton *baton)
|
|
145
|
-
{
|
|
146
|
-
uint32_t flags = DPI_SODA_FLAGS_DEFAULT;
|
|
147
|
-
|
|
148
|
-
if (baton->autoCommit)
|
|
149
|
-
flags |= DPI_SODA_FLAGS_ATOMIC_COMMIT;
|
|
150
|
-
if (dpiSodaDocCursor_getNext(baton->dpiSodaDocCursorHandle, flags,
|
|
151
|
-
&baton->dpiSodaDocHandle) < 0 )
|
|
152
|
-
baton->GetDPIError();
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
//-----------------------------------------------------------------------------
|
|
157
|
-
// njsSodaDocCursor::Async_AfterGetNext()
|
|
158
|
-
// Returns a SODA document if one was found, or undefined if not.
|
|
159
|
-
//-----------------------------------------------------------------------------
|
|
160
|
-
void njsSodaDocCursor::Async_AfterGetNext(njsBaton *baton, Local<Value> argv[])
|
|
161
|
-
{
|
|
162
|
-
if (baton->dpiSodaDocHandle)
|
|
163
|
-
argv[1] = njsSodaDocument::CreateFromBaton(baton);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
//-----------------------------------------------------------------------------
|
|
168
|
-
// njsSodaDocCursor::Close()
|
|
169
|
-
// Close the cursor. The reference to the ODPI-C document cursor is
|
|
170
|
-
// transferred to the baton so that it will be released as soon as possible. It
|
|
171
|
-
// is restored upon failure, however.
|
|
172
|
-
//-----------------------------------------------------------------------------
|
|
173
|
-
NAN_METHOD(njsSodaDocCursor::Close)
|
|
174
|
-
{
|
|
175
|
-
njsSodaDocCursor *cursor = (njsSodaDocCursor*) ValidateArgs(info, 1, 1);
|
|
176
|
-
if (!cursor)
|
|
177
|
-
return;
|
|
178
|
-
|
|
179
|
-
njsBaton *baton = cursor->CreateBaton(info);
|
|
180
|
-
if (!baton)
|
|
181
|
-
return;
|
|
182
|
-
|
|
183
|
-
baton->dpiSodaDocCursorHandle = cursor->dpiSodaDocCursorHandle;
|
|
184
|
-
cursor->dpiSodaDocCursorHandle = NULL;
|
|
185
|
-
baton->QueueWork("Close", Async_Close, NULL, 1);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
//-----------------------------------------------------------------------------
|
|
190
|
-
// njsSodaDocCursor::Async_Close()
|
|
191
|
-
// Actually closes the cursor. If the close fails, however, restore the
|
|
192
|
-
// ODPI-C handle. If it succeds, the baton destructor will automatically
|
|
193
|
-
// release the handle.
|
|
194
|
-
//-----------------------------------------------------------------------------
|
|
195
|
-
void njsSodaDocCursor::Async_Close(njsBaton *baton)
|
|
196
|
-
{
|
|
197
|
-
if (dpiSodaDocCursor_close(baton->dpiSodaDocCursorHandle) < 0 ) {
|
|
198
|
-
njsSodaDocCursor *cursor = (njsSodaDocCursor*) baton->callingObj;
|
|
199
|
-
cursor->dpiSodaDocCursorHandle = baton->dpiSodaDocCursorHandle;
|
|
200
|
-
baton->dpiSodaDocCursorHandle = NULL;
|
|
201
|
-
baton->GetDPIError();
|
|
202
|
-
}
|
|
203
|
-
}
|