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.
Files changed (112) hide show
  1. package/CHANGELOG.md +135 -8
  2. package/README.md +6 -4
  3. package/build/Release/oracledb-abi48-darwin-x64.node +0 -0
  4. package/build/Release/oracledb-abi48-darwin-x64.node-buildinfo.txt +1 -0
  5. package/build/Release/oracledb-abi48-linux-x64.node +0 -0
  6. package/build/Release/oracledb-abi48-linux-x64.node-buildinfo.txt +1 -0
  7. package/build/Release/oracledb-abi48-win32-x64.node +0 -0
  8. package/build/Release/oracledb-abi48-win32-x64.node-buildinfo.txt +1 -0
  9. package/build/Release/oracledb-abi57-darwin-x64.node +0 -0
  10. package/build/Release/oracledb-abi57-darwin-x64.node-buildinfo.txt +1 -0
  11. package/build/Release/oracledb-abi57-linux-x64.node +0 -0
  12. package/build/Release/oracledb-abi57-linux-x64.node-buildinfo.txt +1 -0
  13. package/build/Release/oracledb-abi57-win32-x64.node +0 -0
  14. package/build/Release/oracledb-abi57-win32-x64.node-buildinfo.txt +1 -0
  15. package/build/Release/oracledb-abi64-darwin-x64.node +0 -0
  16. package/build/Release/oracledb-abi64-darwin-x64.node-buildinfo.txt +1 -0
  17. package/build/Release/oracledb-abi64-linux-x64.node +0 -0
  18. package/build/Release/oracledb-abi64-linux-x64.node-buildinfo.txt +1 -0
  19. package/build/Release/oracledb-abi64-win32-x64.node +0 -0
  20. package/build/Release/oracledb-abi64-win32-x64.node-buildinfo.txt +1 -0
  21. package/build/Release/oracledb-abi67-darwin-x64.node +0 -0
  22. package/build/Release/oracledb-abi67-darwin-x64.node-buildinfo.txt +1 -0
  23. package/build/Release/oracledb-abi67-linux-x64.node +0 -0
  24. package/build/Release/oracledb-abi67-linux-x64.node-buildinfo.txt +1 -0
  25. package/build/Release/oracledb-abi67-win32-x64.node +0 -0
  26. package/build/Release/oracledb-abi67-win32-x64.node-buildinfo.txt +1 -0
  27. package/lib/connection.js +18 -4
  28. package/lib/oracledb.js +44 -92
  29. package/lib/pool.js +36 -2
  30. package/lib/sodaCollection.js +1 -1
  31. package/lib/sodaDatabase.js +1 -1
  32. package/lib/util.js +82 -5
  33. package/package/README.md +32 -101
  34. package/package/install.js +139 -0
  35. package/package/prunebinaries.js +51 -0
  36. package/package.json +4 -11
  37. package/binding.gyp +0 -162
  38. package/lib/rel.txt +0 -1
  39. package/odpi/.npmignore +0 -4
  40. package/odpi/LICENSE.md +0 -218
  41. package/odpi/README.md +0 -61
  42. package/odpi/embed/README.md +0 -4
  43. package/odpi/embed/dpi.c +0 -50
  44. package/odpi/include/dpi.h +0 -1748
  45. package/odpi/src/dpiConn.c +0 -2089
  46. package/odpi/src/dpiContext.c +0 -296
  47. package/odpi/src/dpiData.c +0 -797
  48. package/odpi/src/dpiDebug.c +0 -184
  49. package/odpi/src/dpiDeqOptions.c +0 -370
  50. package/odpi/src/dpiEnqOptions.c +0 -174
  51. package/odpi/src/dpiEnv.c +0 -189
  52. package/odpi/src/dpiError.c +0 -204
  53. package/odpi/src/dpiErrorMessages.h +0 -86
  54. package/odpi/src/dpiGen.c +0 -303
  55. package/odpi/src/dpiGlobal.c +0 -292
  56. package/odpi/src/dpiHandleList.c +0 -117
  57. package/odpi/src/dpiHandlePool.c +0 -118
  58. package/odpi/src/dpiImpl.h +0 -1707
  59. package/odpi/src/dpiLob.c +0 -506
  60. package/odpi/src/dpiMsgProps.c +0 -386
  61. package/odpi/src/dpiObject.c +0 -897
  62. package/odpi/src/dpiObjectAttr.c +0 -115
  63. package/odpi/src/dpiObjectType.c +0 -326
  64. package/odpi/src/dpiOci.c +0 -3527
  65. package/odpi/src/dpiOracleType.c +0 -492
  66. package/odpi/src/dpiPool.c +0 -549
  67. package/odpi/src/dpiRowid.c +0 -136
  68. package/odpi/src/dpiSodaColl.c +0 -685
  69. package/odpi/src/dpiSodaCollCursor.c +0 -143
  70. package/odpi/src/dpiSodaDb.c +0 -432
  71. package/odpi/src/dpiSodaDoc.c +0 -230
  72. package/odpi/src/dpiSodaDocCursor.c +0 -143
  73. package/odpi/src/dpiStmt.c +0 -1797
  74. package/odpi/src/dpiSubscr.c +0 -674
  75. package/odpi/src/dpiUtils.c +0 -410
  76. package/odpi/src/dpiVar.c +0 -1794
  77. package/package/MAKEPKG.BAT +0 -156
  78. package/package/Makefile +0 -85
  79. package/package/createpackage.js +0 -186
  80. package/package/extractpackage.js +0 -76
  81. package/package/getversion.js +0 -37
  82. package/package/oracledbinstall.js +0 -497
  83. package/package/package.json +0 -54
  84. package/package/util.js +0 -286
  85. package/src/njsCommon.cpp +0 -1055
  86. package/src/njsCommon.h +0 -484
  87. package/src/njsConnection.cpp +0 -2926
  88. package/src/njsConnection.h +0 -227
  89. package/src/njsIntLob.cpp +0 -618
  90. package/src/njsIntLob.h +0 -179
  91. package/src/njsMessages.cpp +0 -122
  92. package/src/njsMessages.h +0 -118
  93. package/src/njsOracle.cpp +0 -1274
  94. package/src/njsOracle.h +0 -237
  95. package/src/njsPool.cpp +0 -482
  96. package/src/njsPool.h +0 -132
  97. package/src/njsResultSet.cpp +0 -478
  98. package/src/njsResultSet.h +0 -120
  99. package/src/njsSodaCollection.cpp +0 -507
  100. package/src/njsSodaCollection.h +0 -128
  101. package/src/njsSodaDatabase.cpp +0 -335
  102. package/src/njsSodaDatabase.h +0 -108
  103. package/src/njsSodaDocCursor.cpp +0 -203
  104. package/src/njsSodaDocCursor.h +0 -94
  105. package/src/njsSodaDocument.cpp +0 -412
  106. package/src/njsSodaDocument.h +0 -105
  107. package/src/njsSodaOperation.cpp +0 -557
  108. package/src/njsSodaOperation.h +0 -123
  109. package/src/njsSubscription.cpp +0 -388
  110. package/src/njsSubscription.h +0 -111
  111. package/src/njsUtils.cpp +0 -158
  112. package/src/njsUtils.h +0 -68
@@ -1,557 +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
- * njsSodaOperation.cpp
45
- *
46
- * DESCRIPTION
47
- * SodaOperation class implementation.
48
- *
49
- * NOTE:
50
- * This object is a pseudo object, and encapsulates the criteria used to
51
- * perform operations on a SODA collection.
52
- *
53
- ************************************************************************/
54
-
55
- #include "njsOracle.h"
56
- #include "njsSodaOperation.h"
57
- #include "njsSodaDocument.h"
58
- #include "njsSodaDocCursor.h"
59
- #include "njsUtils.h"
60
-
61
- // static member variable
62
- Nan::Persistent<FunctionTemplate>
63
- njsSodaOperation::sodaOperationTemplate_s;
64
-
65
-
66
- //-----------------------------------------------------------------------------
67
- // njsSodaOperation::Init
68
- // Initialization function of SodaOperation class, Maps functions and
69
- // properties from JS to C++
70
- //-----------------------------------------------------------------------------
71
- void njsSodaOperation::Init(Local<Object> target)
72
- {
73
- Nan::HandleScope scope;
74
- Local<FunctionTemplate> tpl = Nan::New<FunctionTemplate>(New);
75
-
76
- tpl->InstanceTemplate()->SetInternalFieldCount(1);
77
- tpl->SetClassName(Nan::New<v8::String>("SodaOperation").ToLocalChecked());
78
-
79
- // Methods
80
- Nan::SetPrototypeMethod(tpl, "count", Count);
81
- Nan::SetPrototypeMethod(tpl, "getOne", GetOne);
82
- Nan::SetPrototypeMethod(tpl, "replaceOne", ReplaceOne);
83
- Nan::SetPrototypeMethod(tpl, "replaceOneAndGet", ReplaceOneAndGet);
84
- Nan::SetPrototypeMethod(tpl, "remove", Remove);
85
- Nan::SetPrototypeMethod(tpl, "getCursor", GetCursor);
86
- Nan::SetPrototypeMethod(tpl, "getDocuments", GetDocuments);
87
-
88
- sodaOperationTemplate_s.Reset(tpl);
89
- Nan::Set(target, Nan::New<v8::String>("SodaOperation").ToLocalChecked(),
90
- tpl->GetFunction());
91
- }
92
-
93
-
94
- //-----------------------------------------------------------------------------
95
- // njsSodaOperation::New()
96
- // Create new object accesible from JS. This is always called from within
97
- // CreateSodaOp() and never from any external JS.
98
- //-----------------------------------------------------------------------------
99
- NAN_METHOD(njsSodaOperation::New)
100
- {
101
- njsSodaOperation *op = new njsSodaOperation();
102
- op->Wrap(info.Holder());
103
- info.GetReturnValue().Set(info.Holder());
104
- }
105
-
106
-
107
- //-----------------------------------------------------------------------------
108
- // njsSodaOperation::Create()
109
- // Creates a new SodaOperation instance.
110
- //-----------------------------------------------------------------------------
111
- Local<Object> njsSodaOperation::Create(dpiSodaColl *coll, dpiSodaDb *db,
112
- Nan::Persistent<Object> &jsOracledb)
113
- {
114
- Nan::EscapableHandleScope scope;
115
- Local<Function> func;
116
- njsSodaOperation *op;
117
- Local<Object> obj;
118
-
119
- func = Nan::GetFunction(Nan::New<FunctionTemplate>(
120
- sodaOperationTemplate_s)).ToLocalChecked();
121
- obj = Nan::NewInstance(func).ToLocalChecked();
122
- op = Nan::ObjectWrap::Unwrap<njsSodaOperation>(obj);
123
- dpiSodaColl_addRef(coll);
124
- op->dpiSodaCollHandle = coll;
125
- op->dpiSodaDbHandle = db;
126
- op->jsOracledb.Reset(jsOracledb);
127
-
128
- return scope.Escape(obj);
129
- }
130
-
131
-
132
- //-----------------------------------------------------------------------------
133
- // njsSodaOperation::ProcessOptions()
134
- // Utility function which processes the options passed through from
135
- // Javascript and turns them into the options expected by ODPI-C.
136
- //-----------------------------------------------------------------------------
137
- bool njsSodaOperation::ProcessOptions(njsBaton *baton,
138
- Local<Object> options)
139
- {
140
- // basic processing to set handles and autocommit flag
141
- baton->SetDPISodaCollHandle(dpiSodaCollHandle);
142
- baton->SetDPISodaDbHandle(dpiSodaDbHandle);
143
- baton->jsOracledb.Reset(jsOracledb);
144
- baton->autoCommit = baton->GetOracledb()->getAutoCommit();
145
-
146
- // initialize SODA operations options structure
147
- baton->sodaOperOptions = new dpiSodaOperOptions();
148
- memset(baton->sodaOperOptions, 0, sizeof(dpiSodaOperOptions));
149
-
150
- // process each of the options
151
- if (!baton->GetUnsignedIntFromJSON(options, "limit", 0,
152
- &baton->sodaOperOptions->limit))
153
- return false;
154
- if (!baton->GetUnsignedIntFromJSON(options, "skip", 0,
155
- &baton->sodaOperOptions->skip))
156
- return false;
157
- if (!baton->GetStringFromJSON(options, "filter", 0, baton->filter))
158
- return false;
159
- if (!baton->GetStringFromJSON(options, "version", 0, baton->version))
160
- return false;
161
- if (!baton->GetStringFromJSON(options, "key", 0, baton->key))
162
- return false;
163
- if (!njsUtils::GetStringArrayFromJSON(options, "keys", 0, baton->keysVec,
164
- baton->error))
165
- return false;
166
-
167
- // populate SODDA operations options structure
168
- baton->sodaOperOptions->filter = baton->filter.c_str();
169
- baton->sodaOperOptions->filterLength = baton->filter.length();
170
- baton->sodaOperOptions->version = baton->version.c_str();
171
- baton->sodaOperOptions->versionLength = baton->version.length();
172
- baton->sodaOperOptions->key = baton->key.c_str();
173
- baton->sodaOperOptions->keyLength = baton->key.length();
174
- if (baton->keysVec.size() > 0) {
175
- uint32_t count = baton->keysVec.size();
176
- baton->sodaOperOptions->keys = (const char **) new char*[count];
177
- baton->sodaOperOptions->keyLengths = new uint32_t[count];
178
- for (uint32_t i = 0; i < count; i++) {
179
- baton->sodaOperOptions->keys[i] = baton->keysVec[i].c_str();
180
- baton->sodaOperOptions->keyLengths[i] = baton->keysVec[i].length();
181
- }
182
- baton->sodaOperOptions->numKeys = count;
183
- }
184
- return true;
185
- }
186
-
187
-
188
- //-----------------------------------------------------------------------------
189
- // njsSodaOperation::Count()
190
- // Returns a count of the number of documents that match the specified
191
- // criteria.
192
- //-----------------------------------------------------------------------------
193
- NAN_METHOD(njsSodaOperation::Count)
194
- {
195
- njsSodaOperation *op = (njsSodaOperation*) ValidateArgs(info, 2, 2);
196
- if (!op)
197
- return;
198
-
199
- njsBaton *baton = op->CreateBaton(info);
200
- if (!baton)
201
- return;
202
-
203
- op->ProcessOptions(baton, info[0].As<Object>());
204
- baton->QueueWork("Count", Async_Count, Async_AfterCount, 2);
205
- }
206
-
207
-
208
- //-----------------------------------------------------------------------------
209
- // njsSodaOperation::Async_Count()
210
- // Worker thread method to acquire the count of the number of documents that
211
- // match the specified criteria.
212
- //-----------------------------------------------------------------------------
213
- void njsSodaOperation::Async_Count(njsBaton *baton)
214
- {
215
- uint32_t flags = DPI_SODA_FLAGS_DEFAULT;
216
-
217
- if (baton->autoCommit)
218
- flags |= DPI_SODA_FLAGS_ATOMIC_COMMIT;
219
- if (dpiSodaColl_getDocCount(baton->dpiSodaCollHandle,
220
- baton->sodaOperOptions, flags, &baton->docCount) < 0)
221
- baton->GetDPIError();
222
- }
223
-
224
-
225
- //-----------------------------------------------------------------------------
226
- // njsSodaOperation::Async_AfterCount()
227
- // Returns the count of the number of documents that match the specified
228
- // criteria.
229
- //-----------------------------------------------------------------------------
230
- void njsSodaOperation::Async_AfterCount(njsBaton *baton,
231
- Local<Value> argv[])
232
- {
233
- Nan::EscapableHandleScope scope;
234
- Local<Object> result = Nan::New<v8::Object>();
235
-
236
- Nan::Set(result, Nan::New<v8::String>("count").ToLocalChecked(),
237
- Nan::New<v8::Integer>((uint32_t)baton->docCount));
238
- argv[1] = scope.Escape(result);
239
- }
240
-
241
-
242
- //-----------------------------------------------------------------------------
243
- // njsSodaOperation::GetOne()
244
- // Returns the first document that matches the specified criteria if one was
245
- // found; otherwise, it returns undefined.
246
- //-----------------------------------------------------------------------------
247
- NAN_METHOD(njsSodaOperation::GetOne)
248
- {
249
- njsSodaOperation *op = (njsSodaOperation*) ValidateArgs(info, 2, 2);
250
- if (!op)
251
- return;
252
-
253
- njsBaton *baton = op->CreateBaton(info);
254
- if (!baton)
255
- return;
256
-
257
- op->ProcessOptions(baton, info[0].As<Object>());
258
- baton->QueueWork("GetOne", Async_GetOne, Async_AfterGetOne, 2);
259
- }
260
-
261
-
262
- //-----------------------------------------------------------------------------
263
- // njsSodaOperation::Async_GetOne()
264
- // Worker thread function to acquire the first document that matches the
265
- // specified criteria.
266
- //-----------------------------------------------------------------------------
267
- void njsSodaOperation::Async_GetOne(njsBaton *baton)
268
- {
269
- uint32_t flags = DPI_SODA_FLAGS_DEFAULT;
270
-
271
- if (baton->autoCommit)
272
- flags |= DPI_SODA_FLAGS_ATOMIC_COMMIT;
273
-
274
- if (dpiSodaColl_findOne(baton->dpiSodaCollHandle, baton->sodaOperOptions,
275
- flags, &baton->dpiSodaDocHandle) < 0)
276
- baton->GetDPIError();
277
- }
278
-
279
-
280
- //-----------------------------------------------------------------------------
281
- // njsSodaOperation::Async_AfterGetOne()
282
- // Returns the first document that matches the specified criteria, or
283
- // undefined.
284
- //-----------------------------------------------------------------------------
285
- void njsSodaOperation::Async_AfterGetOne(njsBaton *baton, Local<Value> argv[])
286
- {
287
- if (baton->dpiSodaDocHandle)
288
- argv[1] = njsSodaDocument::CreateFromBaton(baton);
289
- }
290
-
291
-
292
- //-----------------------------------------------------------------------------
293
- // njsSodaOperation::ReplaceOne()
294
- // Replaces the document matching the specified criteria with the supplied
295
- // content. If no document is found matching ther criteria, no changes are
296
- // made to the database.
297
- //-----------------------------------------------------------------------------
298
- NAN_METHOD(njsSodaOperation::ReplaceOne)
299
- {
300
- njsSodaOperation *op = (njsSodaOperation*) ValidateArgs(info, 3, 3);
301
- if (!op)
302
- return;
303
-
304
- njsBaton *baton = op->CreateBaton(info);
305
- if (!baton)
306
- return;
307
-
308
- op->ProcessOptions(baton, info[0].As<Object>());
309
- baton->GetSodaDocument(info[1].As<Object>(), op->dpiSodaDbHandle);
310
- baton->QueueWork("ReplaceOne", Async_ReplaceOne, Async_AfterReplaceOne, 2);
311
- }
312
-
313
-
314
- //-----------------------------------------------------------------------------
315
- // njsSodaOperation::Async_ReplaceOne()
316
- // Worker thread function which replaces the document.
317
- //-----------------------------------------------------------------------------
318
- void njsSodaOperation::Async_ReplaceOne(njsBaton *baton)
319
- {
320
- uint32_t flags = DPI_SODA_FLAGS_DEFAULT;
321
-
322
- if (baton->autoCommit)
323
- flags |= DPI_SODA_FLAGS_ATOMIC_COMMIT;
324
- if (dpiSodaColl_replaceOne(baton->dpiSodaCollHandle,
325
- baton->sodaOperOptions, baton->dpiSodaDocHandle, flags,
326
- &baton->replaced, NULL) < 0)
327
- baton->GetDPIError();
328
- }
329
-
330
-
331
- //-----------------------------------------------------------------------------
332
- // njsSodaOperation::Async_AfterReplaceOne()
333
- // Returns a boolean indicating if a replace actually took place or not.
334
- //-----------------------------------------------------------------------------
335
- void njsSodaOperation::Async_AfterReplaceOne(njsBaton *baton,
336
- Local<Value> argv[])
337
- {
338
- Nan::EscapableHandleScope scope;
339
- Local<Object> result = Nan::New<v8::Object>();
340
-
341
- Nan::Set(result, Nan::New<v8::String>("replaced").ToLocalChecked(),
342
- Nan::New<v8::Boolean>((baton->replaced != 0) ? true : false));
343
- argv[1] = scope.Escape(result);
344
- }
345
-
346
-
347
- //-----------------------------------------------------------------------------
348
- // njsSodaOperation::ReplaceOneAndGet()
349
- // Similar to ReplaceOne() but returns a wrapped SodaDocument object back in
350
- // the event that the replace was successful.
351
- //-----------------------------------------------------------------------------
352
- NAN_METHOD(njsSodaOperation::ReplaceOneAndGet)
353
- {
354
- njsSodaOperation *op = (njsSodaOperation*) ValidateArgs(info, 3, 3);
355
- if (!op)
356
- return;
357
-
358
- njsBaton *baton = op->CreateBaton(info);
359
- if (!baton)
360
- return;
361
-
362
- op->ProcessOptions(baton, info[0].As<Object>());
363
- baton->GetSodaDocument(info[1].As<Object>(), op->dpiSodaDbHandle);
364
- baton->QueueWork("ReplaceOne", Async_ReplaceOneAndGet,
365
- Async_AfterReplaceOneAndGet, 2);
366
- }
367
-
368
-
369
- //-----------------------------------------------------------------------------
370
- // njsSodaOperation::Async_ReplaceOneAndGet()
371
- // Worker thread function which replaces the document.
372
- //-----------------------------------------------------------------------------
373
- void njsSodaOperation::Async_ReplaceOneAndGet(njsBaton *baton)
374
- {
375
- uint32_t flags = DPI_SODA_FLAGS_DEFAULT;
376
- dpiSodaDoc *resultDoc;
377
-
378
- if (baton->autoCommit)
379
- flags |= DPI_SODA_FLAGS_ATOMIC_COMMIT;
380
- if (dpiSodaColl_replaceOne(baton->dpiSodaCollHandle,
381
- baton->sodaOperOptions, baton->dpiSodaDocHandle, flags,
382
- &baton->replaced, &resultDoc) < 0)
383
- baton->GetDPIError();
384
- dpiSodaDoc_release(baton->dpiSodaDocHandle);
385
- baton->dpiSodaDocHandle = resultDoc;
386
- }
387
-
388
-
389
- //-----------------------------------------------------------------------------
390
- // njsSodaOperation::Async_AfterReplaceOneAndGet()
391
- // Returns a SodaDocument object back to the application if the replacement
392
- // was successful. Note that this document does not contain any content.
393
- //-----------------------------------------------------------------------------
394
- void njsSodaOperation::Async_AfterReplaceOneAndGet(njsBaton *baton,
395
- Local<Value> argv[])
396
- {
397
- if (baton->dpiSodaDocHandle)
398
- argv[1] = njsSodaDocument::CreateFromBaton(baton);
399
- }
400
-
401
-
402
- //-----------------------------------------------------------------------------
403
- // njsSodaOperation::Remove()
404
- // Removes all documents matching the criteria.
405
- //-----------------------------------------------------------------------------
406
- NAN_METHOD(njsSodaOperation::Remove)
407
- {
408
- njsSodaOperation *op = (njsSodaOperation*) ValidateArgs(info, 2, 2);
409
- if (!op)
410
- return;
411
-
412
- njsBaton *baton = op->CreateBaton(info);
413
- if (!baton)
414
- return;
415
-
416
- op->ProcessOptions(baton, info[0].As<Object>());
417
- baton->QueueWork("ReplaceOne", Async_Remove, Async_AfterRemove, 2);
418
- }
419
-
420
-
421
- //-----------------------------------------------------------------------------
422
- // njsSodaOperation::Async_Remove()
423
- // Worker thread function to remove all documents matching the criteria.
424
- //-----------------------------------------------------------------------------
425
- void njsSodaOperation::Async_Remove(njsBaton *baton)
426
- {
427
- uint32_t flags = DPI_SODA_FLAGS_DEFAULT;
428
-
429
- if (baton->autoCommit)
430
- flags |= DPI_SODA_FLAGS_ATOMIC_COMMIT;
431
- if (dpiSodaColl_remove(baton->dpiSodaCollHandle, baton->sodaOperOptions,
432
- flags, &baton->docsDeleted) < 0)
433
- baton->GetDPIError();
434
- }
435
-
436
-
437
- //-----------------------------------------------------------------------------
438
- // njsSodaOperation::Async_AfterRemove()
439
- // Returns a count of the number of documents that were removed.
440
- //-----------------------------------------------------------------------------
441
- void njsSodaOperation::Async_AfterRemove(njsBaton *baton,
442
- Local<Value> argv[])
443
- {
444
- Nan::EscapableHandleScope scope;
445
- Local<Object> result = Nan::New<v8::Object>();
446
-
447
- Nan::Set(result, Nan::New<v8::String>("count").ToLocalChecked(),
448
- Nan::New<v8::Integer>((uint32_t) baton->docsDeleted));
449
- argv[1] = scope.Escape(result);
450
- }
451
-
452
-
453
- //-----------------------------------------------------------------------------
454
- // njsSodaOperation::GetCursor()
455
- // To obtain a cursor of SODA-documents.
456
- //-----------------------------------------------------------------------------
457
- NAN_METHOD(njsSodaOperation::GetCursor)
458
- {
459
- njsSodaOperation *op = (njsSodaOperation*) ValidateArgs(info, 2, 2 );
460
- if (!op)
461
- return;
462
-
463
- njsBaton *baton = op->CreateBaton(info);
464
- if (!baton)
465
- return;
466
-
467
- op->ProcessOptions(baton, info[0].As<Object>());
468
- baton->QueueWork("GetCursor", Async_GetCursor, Async_AfterGetCursor, 2);
469
- }
470
-
471
-
472
- //-----------------------------------------------------------------------------
473
- // njsSodaOperation::Async_GetCursor()
474
- // Worker thread function to obtain a cursor of SODA-documents.
475
- //-----------------------------------------------------------------------------
476
- void njsSodaOperation::Async_GetCursor(njsBaton *baton)
477
- {
478
- uint32_t flags = DPI_SODA_FLAGS_DEFAULT;
479
-
480
- if (baton->autoCommit)
481
- flags |= DPI_SODA_FLAGS_ATOMIC_COMMIT;
482
- if (dpiSodaColl_find(baton->dpiSodaCollHandle, baton->sodaOperOptions,
483
- flags, &baton->dpiSodaDocCursorHandle) < 0)
484
- baton->GetDPIError();
485
- }
486
-
487
-
488
- //-----------------------------------------------------------------------------
489
- // njsSodaOperation::Async_AfterGetCursor()
490
- // To package a cursor of SODA-documents for JS layer.
491
- //-----------------------------------------------------------------------------
492
- void njsSodaOperation::Async_AfterGetCursor(njsBaton *baton,
493
- Local<Value> argv[])
494
- {
495
- argv[1] = njsSodaDocCursor::CreateFromBaton(baton);
496
- }
497
-
498
-
499
- //-----------------------------------------------------------------------------
500
- // njsSodaOperation::GetDocuments()
501
- // To obtain an array of SODA-documents. NOTE: This uses a cursor internally.
502
- //-----------------------------------------------------------------------------
503
- NAN_METHOD(njsSodaOperation::GetDocuments)
504
- {
505
- njsSodaOperation *op = (njsSodaOperation*) ValidateArgs(info, 2, 2);
506
- if (!op)
507
- return;
508
-
509
- njsBaton *baton = op->CreateBaton(info);
510
- if (!baton)
511
- return;
512
-
513
- op->ProcessOptions(baton, info[0].As<Object>());
514
- baton->QueueWork("GetDocuments", Async_GetDocuments,
515
- Async_AfterGetDocuments, 2);
516
- }
517
-
518
-
519
- //-----------------------------------------------------------------------------
520
- // njsSodaOperation::Async_GetDocuments()
521
- // Worker thread function to obtain an array of SODA-documents. NOTE: This
522
- // uses a cursor internally.
523
- //-----------------------------------------------------------------------------
524
- void njsSodaOperation::Async_GetDocuments(njsBaton *baton)
525
- {
526
- uint32_t flags = DPI_SODA_FLAGS_DEFAULT;
527
- dpiSodaDoc *doc;
528
-
529
- if (baton->autoCommit)
530
- flags |= DPI_SODA_FLAGS_ATOMIC_COMMIT;
531
- if (dpiSodaColl_find(baton->dpiSodaCollHandle, baton->sodaOperOptions,
532
- flags, &baton->dpiSodaDocCursorHandle) < 0) {
533
- baton->GetDPIError();
534
- } else {
535
- while (1) {
536
- if (dpiSodaDocCursor_getNext(baton->dpiSodaDocCursorHandle, flags,
537
- &doc) < 0) {
538
- baton->GetDPIError();
539
- break;
540
- }
541
- if (!doc)
542
- break;
543
- baton->dpiSodaDocsVec.push_back(doc);
544
- }
545
- }
546
- }
547
-
548
-
549
- //-----------------------------------------------------------------------------
550
- // njsSodaOperation::Async_AfterGetDocuments()
551
- // Return the array of documents to the Javascript application.
552
- //-----------------------------------------------------------------------------
553
- void njsSodaOperation::Async_AfterGetDocuments(njsBaton *baton,
554
- Local<Value> argv[])
555
- {
556
- argv[1] = njsSodaDocument::CreateArrayFromBaton(baton);
557
- }
@@ -1,123 +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
- * njsSodaOperation.h
45
- *
46
- * DESCRIPTION
47
- * SodaOperation class
48
- *
49
- *****************************************************************************/
50
-
51
- #ifndef __NJSSODAOP_H__
52
- #define __NJSSODAOP_H__
53
-
54
- #include "njsCommon.h"
55
-
56
- class njsSodaOperation : public njsCommon {
57
- public:
58
- static void Init(Local<Object> target);
59
- static Local<Object> Create(dpiSodaColl *coll, dpiSodaDb *db,
60
- Nan::Persistent<Object> &js);
61
-
62
- private:
63
- static NAN_METHOD(New);
64
-
65
- static NAN_METHOD(Count);
66
- static void Async_Count(njsBaton *baton);
67
- static void Async_AfterCount(njsBaton *baton, Local<Value> argv[]);
68
-
69
- static NAN_METHOD(GetOne);
70
- static void Async_GetOne(njsBaton *baton);
71
- static void Async_AfterGetOne(njsBaton *baton, Local<Value> argv[]);
72
-
73
- static NAN_METHOD(ReplaceOne);
74
- static void Async_ReplaceOne(njsBaton *baton);
75
- static void Async_AfterReplaceOne(njsBaton *baton, Local<Value> argv[]);
76
-
77
- static NAN_METHOD(ReplaceOneAndGet);
78
- static void Async_ReplaceOneAndGet(njsBaton *baton);
79
- static void Async_AfterReplaceOneAndGet(njsBaton *baton,
80
- Local<Value> argv[]);
81
-
82
- static NAN_METHOD(Remove);
83
- static void Async_Remove(njsBaton *baton);
84
- static void Async_AfterRemove(njsBaton *baton, Local<Value> argv[]);
85
-
86
- static NAN_METHOD(GetCursor);
87
- static void Async_GetCursor(njsBaton *baton);
88
- static void Async_AfterGetCursor(njsBaton *baton, Local<Value> argv[]);
89
-
90
- static NAN_METHOD(GetDocuments);
91
- static void Async_GetDocuments(njsBaton *baton);
92
- static void Async_AfterGetDocuments(njsBaton *baton, Local<Value> argv[]);
93
-
94
- bool IsValid() const { return true; }
95
-
96
- njsErrorType GetInvalidErrorType() const { return errSuccess; }
97
-
98
- // constructor
99
- njsSodaOperation() : dpiSodaCollHandle(NULL), dpiSodaDbHandle(NULL) { }
100
-
101
- // destructor; do not release SODA database handle as a separate reference
102
- // is not obtained for it
103
- ~njsSodaOperation() {
104
- if (dpiSodaCollHandle) {
105
- dpiSodaColl_release(dpiSodaCollHandle);
106
- dpiSodaCollHandle = NULL;
107
- }
108
- jsOracledb.Reset();
109
- }
110
-
111
- // Utility functions
112
- bool ProcessOptions(njsBaton *baton, Local<Object> options);
113
-
114
- // member variables
115
- dpiSodaColl *dpiSodaCollHandle;
116
- dpiSodaDb *dpiSodaDbHandle;
117
- Nan::Persistent<Object> jsOracledb;
118
-
119
- // static member variables
120
- static Nan::Persistent<FunctionTemplate> sodaOperationTemplate_s;
121
- };
122
-
123
- #endif // __NJSSODAOP_H__