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
|
@@ -1,507 +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
|
-
* njsSodaCollection.cpp
|
|
45
|
-
*
|
|
46
|
-
* DESCRIPTION
|
|
47
|
-
* SodaCollection class implementation.
|
|
48
|
-
*
|
|
49
|
-
****************************************************************************/
|
|
50
|
-
|
|
51
|
-
#include "njsOracle.h"
|
|
52
|
-
#include "njsSodaCollection.h"
|
|
53
|
-
#include "njsSodaDocument.h"
|
|
54
|
-
#include "njsSodaOperation.h"
|
|
55
|
-
|
|
56
|
-
using namespace std;
|
|
57
|
-
|
|
58
|
-
Nan::Persistent<FunctionTemplate> njsSodaCollection::sodaCollTemplate_s;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
//-----------------------------------------------------------------------------
|
|
62
|
-
// njsSodaCollection::Init()
|
|
63
|
-
// Initialization function of SodaCollection class. Maps functions and
|
|
64
|
-
// properties from JS to C++.
|
|
65
|
-
//-----------------------------------------------------------------------------
|
|
66
|
-
void njsSodaCollection::Init(Local<Object> target)
|
|
67
|
-
{
|
|
68
|
-
Nan::HandleScope scope;
|
|
69
|
-
Local<FunctionTemplate> tpl =
|
|
70
|
-
Nan::New<FunctionTemplate>(njsSodaCollection::New);
|
|
71
|
-
tpl->InstanceTemplate()->SetInternalFieldCount(1);
|
|
72
|
-
tpl->SetClassName(Nan::New<v8::String>("Collection").ToLocalChecked());
|
|
73
|
-
|
|
74
|
-
Nan::SetPrototypeMethod(tpl, "drop", DropCollection);
|
|
75
|
-
Nan::SetPrototypeMethod(tpl, "insertOne", InsertOne);
|
|
76
|
-
Nan::SetPrototypeMethod(tpl, "insertOneAndGet", InsertOneAndGet);
|
|
77
|
-
Nan::SetPrototypeMethod(tpl, "createIndex", CreateIndex);
|
|
78
|
-
Nan::SetPrototypeMethod(tpl, "dropIndex", DropIndex);
|
|
79
|
-
Nan::SetPrototypeMethod(tpl, "getDataGuide", GetDataGuide);
|
|
80
|
-
Nan::SetPrototypeMethod(tpl, "find", Find);
|
|
81
|
-
|
|
82
|
-
// Properties
|
|
83
|
-
Nan::SetAccessor(tpl->InstanceTemplate(),
|
|
84
|
-
Nan::New<v8::String>("name").ToLocalChecked(),
|
|
85
|
-
njsSodaCollection::GetCollectionName,
|
|
86
|
-
njsSodaCollection::SetCollectionName);
|
|
87
|
-
|
|
88
|
-
Nan::SetAccessor(tpl->InstanceTemplate(),
|
|
89
|
-
Nan::New<v8::String>("metaData").ToLocalChecked(),
|
|
90
|
-
njsSodaCollection::GetCollectionMetaData,
|
|
91
|
-
njsSodaCollection::SetCollectionMetaData);
|
|
92
|
-
|
|
93
|
-
sodaCollTemplate_s.Reset(tpl);
|
|
94
|
-
Nan::Set(target, Nan::New<v8::String>("Collection").ToLocalChecked(),
|
|
95
|
-
tpl->GetFunction());
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
//-----------------------------------------------------------------------------
|
|
100
|
-
// njsSodaCollection::New()
|
|
101
|
-
// Create new object accesible from JS. This is always called from within
|
|
102
|
-
// CreateFromBaton() and never from any external JS.
|
|
103
|
-
//-----------------------------------------------------------------------------
|
|
104
|
-
NAN_METHOD(njsSodaCollection::New)
|
|
105
|
-
{
|
|
106
|
-
njsSodaCollection *coll = new njsSodaCollection();
|
|
107
|
-
coll->Wrap(info.Holder());
|
|
108
|
-
info.GetReturnValue().Set(info.Holder());
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
//-----------------------------------------------------------------------------
|
|
113
|
-
// njsSodaCollection::CreateFromBaton()
|
|
114
|
-
// Creates a new SodaCollection from the baton. The references to the ODPI-C
|
|
115
|
-
// SODA database and collection are transferred to the ownership of the newly
|
|
116
|
-
// created object.
|
|
117
|
-
//-----------------------------------------------------------------------------
|
|
118
|
-
Local<Object> njsSodaCollection::CreateFromBaton(njsBaton *baton)
|
|
119
|
-
{
|
|
120
|
-
Nan::EscapableHandleScope scope;
|
|
121
|
-
njsSodaCollection *coll;
|
|
122
|
-
Local<Function> func;
|
|
123
|
-
Local<Object> obj;
|
|
124
|
-
|
|
125
|
-
func = Nan::GetFunction(
|
|
126
|
-
Nan::New<FunctionTemplate>(sodaCollTemplate_s)).ToLocalChecked();
|
|
127
|
-
obj = Nan::NewInstance(func).ToLocalChecked();
|
|
128
|
-
coll = Nan::ObjectWrap::Unwrap<njsSodaCollection>(obj);
|
|
129
|
-
coll->dpiSodaCollHandle = baton->dpiSodaCollHandle;
|
|
130
|
-
coll->dpiSodaDbHandle = baton->dpiSodaDbHandle;
|
|
131
|
-
coll->jsOracledb.Reset(baton->jsOracledb);
|
|
132
|
-
baton->dpiSodaCollHandle = NULL;
|
|
133
|
-
return scope.Escape(obj);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
//-----------------------------------------------------------------------------
|
|
138
|
-
// njsSodaCollection::DropCollection()
|
|
139
|
-
// Drops the current collection.
|
|
140
|
-
//-----------------------------------------------------------------------------
|
|
141
|
-
NAN_METHOD(njsSodaCollection::DropCollection)
|
|
142
|
-
{
|
|
143
|
-
njsSodaCollection *coll = (njsSodaCollection*) ValidateArgs(info, 1, 1);
|
|
144
|
-
if (!coll)
|
|
145
|
-
return;
|
|
146
|
-
|
|
147
|
-
njsBaton *baton = coll->CreateBaton(info);
|
|
148
|
-
if (!baton)
|
|
149
|
-
return;
|
|
150
|
-
|
|
151
|
-
baton->SetDPISodaCollHandle(coll->dpiSodaCollHandle);
|
|
152
|
-
baton->jsOracledb.Reset(coll->jsOracledb);
|
|
153
|
-
baton->autoCommit = baton->GetOracledb()->getAutoCommit();
|
|
154
|
-
baton->QueueWork("DropCollection", Async_DropCollection,
|
|
155
|
-
Async_AfterDropCollection, 2);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
//-----------------------------------------------------------------------------
|
|
160
|
-
// njsSodaCollection::Async_DropCollection()
|
|
161
|
-
// Worker thread function to drop the SODA collection.
|
|
162
|
-
//-----------------------------------------------------------------------------
|
|
163
|
-
void njsSodaCollection::Async_DropCollection(njsBaton *baton)
|
|
164
|
-
{
|
|
165
|
-
uint32_t flags = DPI_SODA_FLAGS_DEFAULT;
|
|
166
|
-
|
|
167
|
-
if (baton->autoCommit)
|
|
168
|
-
flags |= DPI_SODA_FLAGS_ATOMIC_COMMIT;
|
|
169
|
-
if (dpiSodaColl_drop(baton->dpiSodaCollHandle, flags,
|
|
170
|
-
&baton->isDropped) < 0)
|
|
171
|
-
baton->GetDPIError();
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
//-----------------------------------------------------------------------------
|
|
176
|
-
// njsSodaCollection::Async_AfterDropCollection()
|
|
177
|
-
// Creates the result object which is returned to the Javascript application.
|
|
178
|
-
//-----------------------------------------------------------------------------
|
|
179
|
-
void njsSodaCollection::Async_AfterDropCollection(njsBaton *baton,
|
|
180
|
-
Local<Value> argv[])
|
|
181
|
-
{
|
|
182
|
-
Nan::EscapableHandleScope scope;
|
|
183
|
-
Local<Object> result = Nan::New<v8::Object>();
|
|
184
|
-
|
|
185
|
-
Nan::Set(result, Nan::New<v8::String>("dropped").ToLocalChecked(),
|
|
186
|
-
Nan::New<v8::Boolean>(baton->isDropped));
|
|
187
|
-
argv[1] = scope.Escape(result);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
//-----------------------------------------------------------------------------
|
|
192
|
-
// njsSodaCollection::InsertOne()
|
|
193
|
-
// Inserts a single document into the collection.
|
|
194
|
-
//-----------------------------------------------------------------------------
|
|
195
|
-
NAN_METHOD(njsSodaCollection::InsertOne)
|
|
196
|
-
{
|
|
197
|
-
njsSodaCollection *coll = (njsSodaCollection*) ValidateArgs(info, 2, 2);
|
|
198
|
-
if (!coll)
|
|
199
|
-
return;
|
|
200
|
-
|
|
201
|
-
njsBaton *baton = coll->CreateBaton(info);
|
|
202
|
-
if (!baton)
|
|
203
|
-
return;
|
|
204
|
-
|
|
205
|
-
baton->SetDPISodaCollHandle(coll->dpiSodaCollHandle);
|
|
206
|
-
baton->jsOracledb.Reset(coll->jsOracledb);
|
|
207
|
-
baton->autoCommit = baton->GetOracledb()->getAutoCommit();
|
|
208
|
-
baton->GetSodaDocument(info[0].As<Object>(), coll->dpiSodaDbHandle);
|
|
209
|
-
baton->QueueWork("InsertOne", Async_InsertOne, NULL, 2);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
//-----------------------------------------------------------------------------
|
|
214
|
-
// njsSodaCollection::Async_InsertOne()
|
|
215
|
-
// Worker thread function to insert a given soda-document into the current
|
|
216
|
-
// collection.
|
|
217
|
-
//----------------------------------------------------------------------------
|
|
218
|
-
void njsSodaCollection::Async_InsertOne(njsBaton *baton)
|
|
219
|
-
{
|
|
220
|
-
uint32_t flags = DPI_SODA_FLAGS_DEFAULT;
|
|
221
|
-
|
|
222
|
-
if (baton->autoCommit)
|
|
223
|
-
flags |= DPI_SODA_FLAGS_ATOMIC_COMMIT;
|
|
224
|
-
if (dpiSodaColl_insertOne(baton->dpiSodaCollHandle,
|
|
225
|
-
baton->dpiSodaDocHandle, flags, NULL) < 0)
|
|
226
|
-
baton->GetDPIError();
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
//-----------------------------------------------------------------------------
|
|
231
|
-
// njsSodaCollection::InsertOneAndGet()
|
|
232
|
-
// To insert a given document and return the result-document with metadata
|
|
233
|
-
// of inserted document.
|
|
234
|
-
//-----------------------------------------------------------------------------
|
|
235
|
-
NAN_METHOD(njsSodaCollection::InsertOneAndGet)
|
|
236
|
-
{
|
|
237
|
-
njsSodaCollection *coll = (njsSodaCollection*) ValidateArgs(info, 2, 2);
|
|
238
|
-
if (!coll)
|
|
239
|
-
return;
|
|
240
|
-
|
|
241
|
-
njsBaton *baton = coll->CreateBaton (info);
|
|
242
|
-
if (!baton)
|
|
243
|
-
return;
|
|
244
|
-
|
|
245
|
-
baton->SetDPISodaCollHandle(coll->dpiSodaCollHandle);
|
|
246
|
-
baton->jsOracledb.Reset(coll->jsOracledb);
|
|
247
|
-
baton->autoCommit = baton->GetOracledb()->getAutoCommit();
|
|
248
|
-
baton->GetSodaDocument(info[0].As<Object>(), coll->dpiSodaDbHandle);
|
|
249
|
-
baton->QueueWork("InsertOneAndGet", Async_InsertOneAndGet,
|
|
250
|
-
Async_AfterInsertOneAndGet, 2);
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
//-----------------------------------------------------------------------------
|
|
255
|
-
// njsSodaCollection::Async_InsertOneAndGet()
|
|
256
|
-
// Worker thread function to insert a given soda-document into the current
|
|
257
|
-
// collection. This operation also obatins the result-document.
|
|
258
|
-
//-----------------------------------------------------------------------------
|
|
259
|
-
void njsSodaCollection::Async_InsertOneAndGet(njsBaton *baton)
|
|
260
|
-
{
|
|
261
|
-
uint32_t flags = DPI_SODA_FLAGS_DEFAULT;
|
|
262
|
-
dpiSodaDoc *resultDoc;
|
|
263
|
-
|
|
264
|
-
if (baton->autoCommit)
|
|
265
|
-
flags |= DPI_SODA_FLAGS_ATOMIC_COMMIT;
|
|
266
|
-
if (dpiSodaColl_insertOne(baton->dpiSodaCollHandle,
|
|
267
|
-
baton->dpiSodaDocHandle, flags, &resultDoc) < 0)
|
|
268
|
-
baton->GetDPIError();
|
|
269
|
-
dpiSodaDoc_release(baton->dpiSodaDocHandle);
|
|
270
|
-
baton->dpiSodaDocHandle = resultDoc;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
//-----------------------------------------------------------------------------
|
|
275
|
-
// njsSodaCollection::Async_AfterInsertOneAndGet()
|
|
276
|
-
// To return the result-document of inserted document to the JS layer.
|
|
277
|
-
//-----------------------------------------------------------------------------
|
|
278
|
-
void njsSodaCollection::Async_AfterInsertOneAndGet(njsBaton *baton,
|
|
279
|
-
Local<Value> arg[])
|
|
280
|
-
{
|
|
281
|
-
arg[1] = njsSodaDocument::CreateFromBaton(baton);
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
//-----------------------------------------------------------------------------
|
|
286
|
-
// njsSodaCollection::CreateIndex()
|
|
287
|
-
// To create an index on the document collection
|
|
288
|
-
//-----------------------------------------------------------------------------
|
|
289
|
-
NAN_METHOD(njsSodaCollection::CreateIndex)
|
|
290
|
-
{
|
|
291
|
-
njsSodaCollection *coll = (njsSodaCollection*) ValidateArgs(info, 2, 2);
|
|
292
|
-
if (!coll)
|
|
293
|
-
return;
|
|
294
|
-
|
|
295
|
-
njsBaton *baton = coll->CreateBaton(info);
|
|
296
|
-
if (!baton)
|
|
297
|
-
return;
|
|
298
|
-
|
|
299
|
-
baton->SetDPISodaCollHandle(coll->dpiSodaCollHandle);
|
|
300
|
-
baton->jsOracledb.Reset(coll->jsOracledb);
|
|
301
|
-
baton->autoCommit = baton->GetOracledb()->getAutoCommit();
|
|
302
|
-
coll->GetStringArg(info, 0, baton->indexSpec);
|
|
303
|
-
baton->QueueWork("CreateIndex", Async_CreateIndex, NULL, 1);
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
//-----------------------------------------------------------------------------
|
|
308
|
-
// njsSodaCollection::Async_CreateIndex()
|
|
309
|
-
// Worker thread function to create index on document collection
|
|
310
|
-
//-----------------------------------------------------------------------------
|
|
311
|
-
void njsSodaCollection::Async_CreateIndex(njsBaton *baton)
|
|
312
|
-
{
|
|
313
|
-
uint32_t flags = DPI_SODA_FLAGS_DEFAULT;
|
|
314
|
-
|
|
315
|
-
if (baton->autoCommit)
|
|
316
|
-
flags |= DPI_SODA_FLAGS_ATOMIC_COMMIT;
|
|
317
|
-
if (dpiSodaColl_createIndex(baton->dpiSodaCollHandle,
|
|
318
|
-
baton->indexSpec.c_str(), baton->indexSpec.length(), flags) < 0)
|
|
319
|
-
baton->GetDPIError();
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
//-----------------------------------------------------------------------------
|
|
324
|
-
// njsSodaCollection::DropIndex()
|
|
325
|
-
// To drop an index of document collection
|
|
326
|
-
//-----------------------------------------------------------------------------
|
|
327
|
-
NAN_METHOD(njsSodaCollection::DropIndex)
|
|
328
|
-
{
|
|
329
|
-
njsSodaCollection *coll = (njsSodaCollection*) ValidateArgs(info, 3, 3);
|
|
330
|
-
if (!coll)
|
|
331
|
-
return;
|
|
332
|
-
|
|
333
|
-
njsBaton *baton = coll->CreateBaton(info);
|
|
334
|
-
if (!baton)
|
|
335
|
-
return;
|
|
336
|
-
|
|
337
|
-
baton->SetDPISodaCollHandle(coll->dpiSodaCollHandle);
|
|
338
|
-
baton->jsOracledb.Reset(coll->jsOracledb);
|
|
339
|
-
baton->autoCommit = baton->GetOracledb()->getAutoCommit();
|
|
340
|
-
|
|
341
|
-
Local<Object> options;
|
|
342
|
-
coll->GetStringArg(info, 0, baton->indexName);
|
|
343
|
-
if (coll->GetObjectArg(info, 2, options))
|
|
344
|
-
baton->GetBoolFromJSON(options, "force", 2, &baton->force);
|
|
345
|
-
baton->QueueWork("DropIndex", Async_DropIndex, Async_AfterDropIndex, 2);
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
//-----------------------------------------------------------------------------
|
|
350
|
-
// njsSodaCollection::Async_DropIndex()
|
|
351
|
-
// Worker thread function to drop index
|
|
352
|
-
//-----------------------------------------------------------------------------
|
|
353
|
-
void njsSodaCollection::Async_DropIndex(njsBaton *baton)
|
|
354
|
-
{
|
|
355
|
-
uint32_t flags = DPI_SODA_FLAGS_DEFAULT;
|
|
356
|
-
|
|
357
|
-
if (baton->autoCommit)
|
|
358
|
-
flags |= DPI_SODA_FLAGS_ATOMIC_COMMIT;
|
|
359
|
-
if (baton->force)
|
|
360
|
-
flags |= DPI_SODA_FLAGS_INDEX_DROP_FORCE;
|
|
361
|
-
|
|
362
|
-
if (dpiSodaColl_dropIndex(baton->dpiSodaCollHandle,
|
|
363
|
-
baton->indexName.c_str(), baton->indexName.length(), flags,
|
|
364
|
-
&baton->isDropped) < 0)
|
|
365
|
-
baton->GetDPIError();
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
//-----------------------------------------------------------------------------
|
|
370
|
-
// njsSodaCollection::Async_AfterDropIndex()
|
|
371
|
-
// To package the isDropped flag to application
|
|
372
|
-
//-----------------------------------------------------------------------------
|
|
373
|
-
void njsSodaCollection::Async_AfterDropIndex(njsBaton *baton,
|
|
374
|
-
Local<Value> argv[])
|
|
375
|
-
{
|
|
376
|
-
Nan::EscapableHandleScope scope;
|
|
377
|
-
Local<Object> result = Nan::New<v8::Object>();
|
|
378
|
-
|
|
379
|
-
Nan::Set(result, Nan::New<v8::String>("dropped").ToLocalChecked(),
|
|
380
|
-
Nan::New<v8::Boolean>(baton->isDropped));
|
|
381
|
-
argv[1] = scope.Escape(result);
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
//-----------------------------------------------------------------------------
|
|
386
|
-
// njsSodaCollection::GetDataGuide()
|
|
387
|
-
// To obtain dataGuide
|
|
388
|
-
//-----------------------------------------------------------------------------
|
|
389
|
-
NAN_METHOD(njsSodaCollection::GetDataGuide)
|
|
390
|
-
{
|
|
391
|
-
njsSodaCollection *coll = (njsSodaCollection*) ValidateArgs(info, 1, 1);
|
|
392
|
-
if (!coll)
|
|
393
|
-
return;
|
|
394
|
-
|
|
395
|
-
njsBaton *baton = coll->CreateBaton(info);
|
|
396
|
-
if (!baton)
|
|
397
|
-
return;
|
|
398
|
-
|
|
399
|
-
baton->SetDPISodaCollHandle(coll->dpiSodaCollHandle);
|
|
400
|
-
baton->QueueWork("GetDataGuide", Async_GetDataGuide,
|
|
401
|
-
Async_AfterGetDataGuide, 2);
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
//-----------------------------------------------------------------------------
|
|
406
|
-
// njsSodaCollection::Async_GetDataGuide()
|
|
407
|
-
// Worker thread function to obtain the data guide
|
|
408
|
-
//-----------------------------------------------------------------------------
|
|
409
|
-
void njsSodaCollection::Async_GetDataGuide(njsBaton *baton)
|
|
410
|
-
{
|
|
411
|
-
if (dpiSodaColl_getDataGuide(baton->dpiSodaCollHandle,
|
|
412
|
-
DPI_SODA_FLAGS_DEFAULT, &baton->dpiSodaDocHandle) < 0)
|
|
413
|
-
baton->GetDPIError();
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
//-----------------------------------------------------------------------------
|
|
418
|
-
// njsSodaCollection::Async_AfterGetDataGuide()
|
|
419
|
-
// To package the dataGuide to application
|
|
420
|
-
//-----------------------------------------------------------------------------
|
|
421
|
-
void njsSodaCollection::Async_AfterGetDataGuide(njsBaton *baton,
|
|
422
|
-
Local<Value> argv[])
|
|
423
|
-
{
|
|
424
|
-
if (baton->dpiSodaDocHandle)
|
|
425
|
-
argv[1] = njsSodaDocument::CreateFromBaton(baton);
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
//-----------------------------------------------------------------------------
|
|
430
|
-
// njsSodaCollection::Find()
|
|
431
|
-
// Create a SodaOperation object.
|
|
432
|
-
//-----------------------------------------------------------------------------
|
|
433
|
-
NAN_METHOD(njsSodaCollection::Find)
|
|
434
|
-
{
|
|
435
|
-
Nan::EscapableHandleScope scope;
|
|
436
|
-
njsSodaCollection* coll = (njsSodaCollection*) ValidateArgs(info, 0, 0);
|
|
437
|
-
if (!coll)
|
|
438
|
-
return;
|
|
439
|
-
|
|
440
|
-
Local<Object> obj = njsSodaOperation::Create(coll->dpiSodaCollHandle,
|
|
441
|
-
coll->dpiSodaDbHandle, coll->jsOracledb);
|
|
442
|
-
info.GetReturnValue().Set(obj);
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
//-----------------------------------------------------------------------------
|
|
447
|
-
// njsSodaCollection::GetCollectionName()
|
|
448
|
-
// To obtain the collection from from collection object
|
|
449
|
-
//-----------------------------------------------------------------------------
|
|
450
|
-
NAN_GETTER(njsSodaCollection::GetCollectionName)
|
|
451
|
-
{
|
|
452
|
-
njsSodaCollection *coll = (njsSodaCollection*) ValidateGetter(info);
|
|
453
|
-
if (!coll)
|
|
454
|
-
return;
|
|
455
|
-
|
|
456
|
-
const char *name;
|
|
457
|
-
uint32_t nameLen;
|
|
458
|
-
if (dpiSodaColl_getName(coll->dpiSodaCollHandle, &name, &nameLen) < 0) {
|
|
459
|
-
njsOracledb::ThrowDPIError();
|
|
460
|
-
return;
|
|
461
|
-
}
|
|
462
|
-
Local<String> value = Nan::New<v8::String>(name, nameLen).ToLocalChecked();
|
|
463
|
-
info.GetReturnValue().Set(value);
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
//-----------------------------------------------------------------------------
|
|
468
|
-
// njsSodaCollection::SetCollectionName()
|
|
469
|
-
// dummy function to handle read-only property being set
|
|
470
|
-
//-----------------------------------------------------------------------------
|
|
471
|
-
NAN_SETTER(njsSodaCollection::SetCollectionName)
|
|
472
|
-
{
|
|
473
|
-
PropertyIsReadOnly("name");
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
//-----------------------------------------------------------------------------
|
|
478
|
-
// njsSodaCollection::GetCollectionMetaData()
|
|
479
|
-
// To obtain collection metadata from collection
|
|
480
|
-
//-----------------------------------------------------------------------------
|
|
481
|
-
NAN_GETTER(njsSodaCollection::GetCollectionMetaData)
|
|
482
|
-
{
|
|
483
|
-
njsSodaCollection *coll = (njsSodaCollection*) ValidateGetter(info);
|
|
484
|
-
if (!coll)
|
|
485
|
-
return;
|
|
486
|
-
|
|
487
|
-
const char *metadata;
|
|
488
|
-
uint32_t metadataLen;
|
|
489
|
-
if (dpiSodaColl_getMetadata(coll->dpiSodaCollHandle, &metadata,
|
|
490
|
-
&metadataLen) < 0) {
|
|
491
|
-
njsOracledb::ThrowDPIError();
|
|
492
|
-
return;
|
|
493
|
-
}
|
|
494
|
-
Local<String> value =
|
|
495
|
-
Nan::New<v8::String>(metadata, metadataLen).ToLocalChecked();
|
|
496
|
-
info.GetReturnValue().Set(value);
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
//-----------------------------------------------------------------------------
|
|
501
|
-
// njsSodaCollection::SetCollectionMetaData()
|
|
502
|
-
// Dummy function to handle read-only property being set
|
|
503
|
-
//-----------------------------------------------------------------------------
|
|
504
|
-
NAN_SETTER(njsSodaCollection::SetCollectionMetaData)
|
|
505
|
-
{
|
|
506
|
-
PropertyIsReadOnly("metaData");
|
|
507
|
-
}
|
package/src/njsSodaCollection.h
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
/* Copyright (c) 2015, 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
|
-
* njsSodaCollection.h
|
|
45
|
-
*
|
|
46
|
-
* DESCRIPTION
|
|
47
|
-
* Connection class implementation.
|
|
48
|
-
*
|
|
49
|
-
*****************************************************************************/
|
|
50
|
-
|
|
51
|
-
#ifndef __NJSSODACOLL_H__
|
|
52
|
-
#define __NJSSODACOLL_H__
|
|
53
|
-
|
|
54
|
-
#include "njsCommon.h"
|
|
55
|
-
|
|
56
|
-
//-----------------------------------------------------------------------------
|
|
57
|
-
// njsSodaCollection
|
|
58
|
-
// Class exposed to JS for handling SODA collections in the database.
|
|
59
|
-
//-----------------------------------------------------------------------------
|
|
60
|
-
class njsSodaCollection : public njsCommon {
|
|
61
|
-
public:
|
|
62
|
-
static void Init(Local<Object> target);
|
|
63
|
-
static Local<Object> CreateFromBaton(njsBaton *baton);
|
|
64
|
-
dpiSodaColl *GetDPISodaColl() const { return dpiSodaCollHandle; }
|
|
65
|
-
|
|
66
|
-
private:
|
|
67
|
-
static Nan::Persistent<FunctionTemplate> sodaCollTemplate_s;
|
|
68
|
-
|
|
69
|
-
static NAN_METHOD(New);
|
|
70
|
-
|
|
71
|
-
static NAN_METHOD(DropCollection);
|
|
72
|
-
static void Async_DropCollection(njsBaton *baton);
|
|
73
|
-
static void Async_AfterDropCollection(njsBaton *baton, Local<Value> arg[]);
|
|
74
|
-
|
|
75
|
-
static NAN_METHOD(InsertOne);
|
|
76
|
-
static void Async_InsertOne(njsBaton *baton);
|
|
77
|
-
static void Async_AfterInsertOne(njsBaton *baton, Local<Value> arg[]);
|
|
78
|
-
|
|
79
|
-
static NAN_METHOD(InsertOneAndGet);
|
|
80
|
-
static void Async_InsertOneAndGet(njsBaton *baton);
|
|
81
|
-
static void Async_AfterInsertOneAndGet(njsBaton *baton,
|
|
82
|
-
Local<Value> arg[]);
|
|
83
|
-
|
|
84
|
-
static NAN_METHOD(CreateIndex);
|
|
85
|
-
static void Async_CreateIndex(njsBaton *baton);
|
|
86
|
-
|
|
87
|
-
static NAN_METHOD(DropIndex);
|
|
88
|
-
static void Async_DropIndex(njsBaton *baton);
|
|
89
|
-
static void Async_AfterDropIndex(njsBaton *baton, Local<Value> argv[]);
|
|
90
|
-
|
|
91
|
-
static NAN_METHOD(GetDataGuide);
|
|
92
|
-
static void Async_GetDataGuide(njsBaton *baton);
|
|
93
|
-
static void Async_AfterGetDataGuide(njsBaton *baton, Local<Value> argv[]);
|
|
94
|
-
|
|
95
|
-
// find method
|
|
96
|
-
static NAN_METHOD(Find);
|
|
97
|
-
|
|
98
|
-
// Define Getter Accessors to Properties
|
|
99
|
-
static NAN_GETTER(GetCollectionName);
|
|
100
|
-
static NAN_GETTER(GetCollectionMetaData);
|
|
101
|
-
|
|
102
|
-
// Define Setter Accessors to Properties
|
|
103
|
-
static NAN_SETTER(SetCollectionName);
|
|
104
|
-
static NAN_SETTER(SetCollectionMetaData);
|
|
105
|
-
|
|
106
|
-
bool IsValid() const { return true; }
|
|
107
|
-
|
|
108
|
-
njsErrorType GetInvalidErrorType() const { return errSuccess; }
|
|
109
|
-
|
|
110
|
-
// Constructor
|
|
111
|
-
njsSodaCollection() : dpiSodaCollHandle(NULL), dpiSodaDbHandle(NULL) { }
|
|
112
|
-
|
|
113
|
-
// Destructor
|
|
114
|
-
~njsSodaCollection() {
|
|
115
|
-
if (dpiSodaCollHandle) {
|
|
116
|
-
dpiSodaColl_release(dpiSodaCollHandle);
|
|
117
|
-
dpiSodaCollHandle = NULL;
|
|
118
|
-
}
|
|
119
|
-
jsOracledb.Reset();
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
private:
|
|
123
|
-
dpiSodaColl *dpiSodaCollHandle; // Soda Collection
|
|
124
|
-
dpiSodaDb *dpiSodaDbHandle; // Underlying SodaDatabase object
|
|
125
|
-
Nan::Persistent<Object> jsOracledb; // Oracledb object from JS land
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
#endif // ++MKSSPDACOLL_H__
|