couchbase 3.2.2 → 3.2.5
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/binding.gyp +5 -0
- package/deps/lcb/CMakeLists.txt +1 -1
- package/deps/lcb/CONTRIBUTING.md +1 -1
- package/deps/lcb/README.markdown +2 -2
- package/deps/lcb/RELEASE_NOTES.markdown +84 -17
- package/deps/lcb/cmake/Modules/GetVersionInfo.cmake +1 -1
- package/deps/lcb/contrib/cbsasl/src/scram-sha/scram_utils.cc +22 -26
- package/deps/lcb/contrib/lcb-jsoncpp/lcb-jsoncpp.cpp +20 -6
- package/deps/lcb/doc/Doxyfile +1 -1
- package/deps/lcb/example/minimal/query.c +9 -7
- package/deps/lcb/gyp_config/common/libcouchbase/configuration.h +3 -3
- package/deps/lcb/gyp_config/linux/arm64/config.h +243 -0
- package/deps/lcb/include/libcouchbase/couchbase.h +55 -1
- package/deps/lcb/include/libcouchbase/error.h +6 -1
- package/deps/lcb/include/libcouchbase/ixmgmt.h +15 -10
- package/deps/lcb/include/libcouchbase/tracing.h +2 -2
- package/deps/lcb/include/memcached/protocol_binary.h +21 -0
- package/deps/lcb/libcouchbase.gyp +353 -349
- package/deps/lcb/packaging/deb/control +1 -1
- package/deps/lcb/src/analytics/analytics_handle.cc +7 -5
- package/deps/lcb/src/analytics/analytics_handle.hh +28 -0
- package/deps/lcb/src/capi/cmd_counter.hh +18 -0
- package/deps/lcb/src/capi/cmd_exists.hh +18 -0
- package/deps/lcb/src/capi/cmd_get.hh +17 -0
- package/deps/lcb/src/capi/cmd_get_replica.hh +20 -1
- package/deps/lcb/src/capi/cmd_query.cc +13 -0
- package/deps/lcb/src/capi/cmd_query.hh +22 -14
- package/deps/lcb/src/capi/cmd_remove.hh +18 -0
- package/deps/lcb/src/capi/cmd_search.hh +6 -0
- package/deps/lcb/src/capi/cmd_store.hh +28 -21
- package/deps/lcb/src/capi/cmd_subdoc.hh +30 -0
- package/deps/lcb/src/capi/cmd_touch.hh +18 -0
- package/deps/lcb/src/capi/cmd_unlock.hh +18 -0
- package/deps/lcb/src/capi/cmd_view.hh +6 -0
- package/deps/lcb/src/capi/collection_qualifier.hh +6 -8
- package/deps/lcb/src/cntl.cc +42 -8
- package/deps/lcb/src/dns-srv.cc +5 -3
- package/deps/lcb/src/errmap.cc +5 -9
- package/deps/lcb/src/errmap.h +7 -3
- package/deps/lcb/src/handler.cc +24 -18
- package/deps/lcb/src/internal.h +2 -1
- package/deps/lcb/src/lcbio/ctx.cc +4 -2
- package/deps/lcb/src/mcserver/mcserver.cc +8 -5
- package/deps/lcb/src/mcserver/negotiate.cc +42 -17
- package/deps/lcb/src/n1ql/ixmgmt.cc +1 -2
- package/deps/lcb/src/n1ql/n1ql.cc +5 -1
- package/deps/lcb/src/n1ql/query_handle.cc +80 -44
- package/deps/lcb/src/n1ql/query_handle.hh +41 -3
- package/deps/lcb/src/operations/counter.cc +13 -1
- package/deps/lcb/src/operations/exists.cc +14 -2
- package/deps/lcb/src/operations/get.cc +14 -2
- package/deps/lcb/src/operations/get_replica.cc +18 -6
- package/deps/lcb/src/operations/observe.cc +1 -1
- package/deps/lcb/src/operations/remove.cc +13 -1
- package/deps/lcb/src/operations/store.cc +13 -1
- package/deps/lcb/src/operations/subdoc.cc +13 -2
- package/deps/lcb/src/operations/touch.cc +14 -2
- package/deps/lcb/src/operations/unlock.cc +14 -2
- package/deps/lcb/src/search/search_handle.cc +26 -8
- package/deps/lcb/src/search/search_handle.hh +29 -0
- package/deps/lcb/src/ssl/ssl_common.c +7 -8
- package/deps/lcb/src/tracing/span.cc +43 -10
- package/deps/lcb/src/tracing/tracing-internal.h +105 -93
- package/deps/lcb/src/utilities.cc +21 -0
- package/deps/lcb/src/utilities.h +3 -0
- package/deps/lcb/src/views/view_handle.cc +13 -5
- package/deps/lcb/src/views/view_handle.hh +29 -0
- package/deps/lcb/tests/CMakeLists.txt +21 -0
- package/deps/lcb/tests/basic/t_ctlcodes.cc +24 -3
- package/deps/lcb/tests/basic/t_jsparse.cc +8 -0
- package/deps/lcb/tests/iotests/mock-environment.cc +25 -1
- package/deps/lcb/tests/iotests/mock-environment.h +49 -1
- package/deps/lcb/tests/iotests/mock-unit-test.cc +96 -5
- package/deps/lcb/tests/iotests/mock-unit-test.h +32 -0
- package/deps/lcb/tests/iotests/serverparams.h +7 -2
- package/deps/lcb/tests/iotests/t_collections.cc +1 -1
- package/deps/lcb/tests/iotests/t_confmon.cc +4 -2
- package/deps/lcb/tests/iotests/t_get.cc +14 -4
- package/deps/lcb/tests/iotests/t_n1ql.cc +17 -1
- package/deps/lcb/tests/iotests/t_ratelimit.cc +729 -0
- package/deps/lcb/tests/iotests/t_views.cc +1 -0
- package/deps/lcb/tests/iotests/testutil.cc +342 -0
- package/deps/lcb/tests/iotests/testutil.h +164 -0
- package/deps/lcb/tests/mocksupport/procutil.c +32 -28
- package/deps/lcb/tests/mocksupport/server.c +0 -1
- package/deps/lcb/tools/cbc.cc +7 -0
- package/dist/analyticsexecutor.js +2 -2
- package/dist/analyticsindexmanager.js +512 -524
- package/dist/binarycollection.d.ts +17 -0
- package/dist/binding.d.ts +2 -0
- package/dist/binding.js +1 -1
- package/dist/bindingutilities.js +9 -1
- package/dist/bucketmanager.d.ts +32 -23
- package/dist/bucketmanager.js +197 -189
- package/dist/cluster.js +37 -36
- package/dist/collection.js +17 -23
- package/dist/collectionmanager.js +181 -200
- package/dist/connection.js +6 -3
- package/dist/connspec.js +5 -1
- package/dist/couchbase.js +7 -14
- package/dist/datastructures.js +239 -310
- package/dist/diagnosticsexecutor.js +70 -85
- package/dist/errors.d.ts +18 -0
- package/dist/errors.js +26 -2
- package/dist/eventingfunctionmanager.js +267 -294
- package/dist/httpexecutor.js +31 -38
- package/dist/logging.js +1 -1
- package/dist/queryexecutor.js +3 -3
- package/dist/queryindexmanager.js +236 -263
- package/dist/scope.js +8 -2
- package/dist/searchexecutor.js +3 -0
- package/dist/searchindexmanager.js +240 -271
- package/dist/searchquery.d.ts +17 -0
- package/dist/searchquery.js +22 -1
- package/dist/searchtypes.d.ts +7 -2
- package/dist/searchtypes.js +2 -2
- package/dist/usermanager.js +250 -263
- package/dist/utilities.d.ts +3 -2
- package/dist/utilities.js +16 -4
- package/dist/viewexecutor.js +1 -1
- package/dist/viewindexmanager.js +131 -150
- package/package.json +1 -1
- package/src/connection.cpp +2 -0
- package/src/constants.cpp +2 -0
- package/src/instance.cpp +8 -1
- package/src/instance.h +1 -0
- package/src/uv-plugin-all.cpp +1 -0
- package/dist/cas.d.ts +0 -0
- package/dist/cas.js +0 -1
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.QueryIndexManager = exports.QueryIndex = void 0;
|
|
13
4
|
const errors_1 = require("./errors");
|
|
@@ -50,56 +41,54 @@ class QueryIndexManager {
|
|
|
50
41
|
get _http() {
|
|
51
42
|
return new httpexecutor_1.HttpExecutor(this._cluster._getClusterConn());
|
|
52
43
|
}
|
|
53
|
-
_createIndex(bucketName, options, callback) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
qs += ', ';
|
|
71
|
-
}
|
|
72
|
-
qs += '`' + options.fields[i] + '`';
|
|
44
|
+
async _createIndex(bucketName, options, callback) {
|
|
45
|
+
let qs = '';
|
|
46
|
+
if (!options.fields) {
|
|
47
|
+
qs += 'CREATE PRIMARY INDEX';
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
qs += 'CREATE INDEX';
|
|
51
|
+
}
|
|
52
|
+
if (options.name) {
|
|
53
|
+
qs += ' `' + options.name + '`';
|
|
54
|
+
}
|
|
55
|
+
qs += ' ON `' + bucketName + '`';
|
|
56
|
+
if (options.fields && options.fields.length > 0) {
|
|
57
|
+
qs += '(';
|
|
58
|
+
for (let i = 0; i < options.fields.length; ++i) {
|
|
59
|
+
if (i > 0) {
|
|
60
|
+
qs += ', ';
|
|
73
61
|
}
|
|
74
|
-
qs += '
|
|
75
|
-
}
|
|
76
|
-
const withOpts = {};
|
|
77
|
-
if (options.deferred) {
|
|
78
|
-
withOpts.defer_build = true;
|
|
79
|
-
}
|
|
80
|
-
if (options.numReplicas) {
|
|
81
|
-
withOpts.num_replica = options.numReplicas;
|
|
62
|
+
qs += '`' + options.fields[i] + '`';
|
|
82
63
|
}
|
|
83
|
-
|
|
84
|
-
|
|
64
|
+
qs += ')';
|
|
65
|
+
}
|
|
66
|
+
const withOpts = {};
|
|
67
|
+
if (options.deferred) {
|
|
68
|
+
withOpts.defer_build = true;
|
|
69
|
+
}
|
|
70
|
+
if (options.numReplicas) {
|
|
71
|
+
withOpts.num_replica = options.numReplicas;
|
|
72
|
+
}
|
|
73
|
+
if (Object.keys(withOpts).length > 0) {
|
|
74
|
+
qs += ' WITH ' + JSON.stringify(withOpts);
|
|
75
|
+
}
|
|
76
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
77
|
+
try {
|
|
78
|
+
await this._cluster.query(qs, {
|
|
79
|
+
parentSpan: options.parentSpan,
|
|
80
|
+
timeout: options.timeout,
|
|
81
|
+
});
|
|
85
82
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
parentSpan: options.parentSpan,
|
|
90
|
-
timeout: options.timeout,
|
|
91
|
-
});
|
|
83
|
+
catch (err) {
|
|
84
|
+
if (options.ignoreIfExists && err instanceof errors_1.IndexExistsError) {
|
|
85
|
+
// swallow the error if the user wants us to
|
|
92
86
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
// swallow the error if the user wants us to
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
throw err;
|
|
99
|
-
}
|
|
87
|
+
else {
|
|
88
|
+
throw err;
|
|
100
89
|
}
|
|
101
|
-
}
|
|
102
|
-
});
|
|
90
|
+
}
|
|
91
|
+
}, callback);
|
|
103
92
|
}
|
|
104
93
|
/**
|
|
105
94
|
* Creates a new query index.
|
|
@@ -110,25 +99,23 @@ class QueryIndexManager {
|
|
|
110
99
|
* @param options Optional parameters for this operation.
|
|
111
100
|
* @param callback A node-style callback to be invoked after execution.
|
|
112
101
|
*/
|
|
113
|
-
createIndex(bucketName, indexName, fields, options, callback) {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}, callback);
|
|
131
|
-
});
|
|
102
|
+
async createIndex(bucketName, indexName, fields, options, callback) {
|
|
103
|
+
if (options instanceof Function) {
|
|
104
|
+
callback = arguments[3];
|
|
105
|
+
options = undefined;
|
|
106
|
+
}
|
|
107
|
+
if (!options) {
|
|
108
|
+
options = {};
|
|
109
|
+
}
|
|
110
|
+
return this._createIndex(bucketName, {
|
|
111
|
+
name: indexName,
|
|
112
|
+
fields: fields,
|
|
113
|
+
ignoreIfExists: options.ignoreIfExists,
|
|
114
|
+
numReplicas: options.numReplicas,
|
|
115
|
+
deferred: options.deferred,
|
|
116
|
+
parentSpan: options.parentSpan,
|
|
117
|
+
timeout: options.timeout,
|
|
118
|
+
}, callback);
|
|
132
119
|
}
|
|
133
120
|
/**
|
|
134
121
|
* Creates a new primary query index.
|
|
@@ -137,51 +124,47 @@ class QueryIndexManager {
|
|
|
137
124
|
* @param options Optional parameters for this operation.
|
|
138
125
|
* @param callback A node-style callback to be invoked after execution.
|
|
139
126
|
*/
|
|
140
|
-
createPrimaryIndex(bucketName, options, callback) {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
127
|
+
async createPrimaryIndex(bucketName, options, callback) {
|
|
128
|
+
if (options instanceof Function) {
|
|
129
|
+
callback = arguments[1];
|
|
130
|
+
options = undefined;
|
|
131
|
+
}
|
|
132
|
+
if (!options) {
|
|
133
|
+
options = {};
|
|
134
|
+
}
|
|
135
|
+
return this._createIndex(bucketName, {
|
|
136
|
+
name: options.name,
|
|
137
|
+
ignoreIfExists: options.ignoreIfExists,
|
|
138
|
+
deferred: options.deferred,
|
|
139
|
+
parentSpan: options.parentSpan,
|
|
140
|
+
timeout: options.timeout,
|
|
141
|
+
}, callback);
|
|
142
|
+
}
|
|
143
|
+
async _dropIndex(bucketName, options, callback) {
|
|
144
|
+
const timeout = options.timeout;
|
|
145
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
146
|
+
let qs = '';
|
|
147
|
+
if (!options.name) {
|
|
148
|
+
qs += 'DROP PRIMARY INDEX `' + bucketName + '`';
|
|
145
149
|
}
|
|
146
|
-
|
|
147
|
-
options
|
|
150
|
+
else {
|
|
151
|
+
qs += 'DROP INDEX `' + bucketName + '`.`' + options.name + '`';
|
|
148
152
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
_dropIndex(bucketName, options, callback) {
|
|
159
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
160
|
-
const timeout = options.timeout;
|
|
161
|
-
return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
|
|
162
|
-
let qs = '';
|
|
163
|
-
if (!options.name) {
|
|
164
|
-
qs += 'DROP PRIMARY INDEX `' + bucketName + '`';
|
|
153
|
+
try {
|
|
154
|
+
await this._cluster.query(qs, {
|
|
155
|
+
parentSpan: options.parentSpan,
|
|
156
|
+
timeout: timeout,
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
catch (err) {
|
|
160
|
+
if (options.ignoreIfNotExists && err instanceof errors_1.IndexNotFoundError) {
|
|
161
|
+
// swallow the error if the user wants us to
|
|
165
162
|
}
|
|
166
163
|
else {
|
|
167
|
-
|
|
164
|
+
throw err;
|
|
168
165
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
parentSpan: options.parentSpan,
|
|
172
|
-
timeout: timeout,
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
catch (err) {
|
|
176
|
-
if (options.ignoreIfNotExists && err instanceof errors_1.IndexNotFoundError) {
|
|
177
|
-
// swallow the error if the user wants us to
|
|
178
|
-
}
|
|
179
|
-
else {
|
|
180
|
-
throw err;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
}), callback);
|
|
184
|
-
});
|
|
166
|
+
}
|
|
167
|
+
}, callback);
|
|
185
168
|
}
|
|
186
169
|
/**
|
|
187
170
|
* Drops an existing query index.
|
|
@@ -191,22 +174,20 @@ class QueryIndexManager {
|
|
|
191
174
|
* @param options Optional parameters for this operation.
|
|
192
175
|
* @param callback A node-style callback to be invoked after execution.
|
|
193
176
|
*/
|
|
194
|
-
dropIndex(bucketName, indexName, options, callback) {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
}, callback);
|
|
209
|
-
});
|
|
177
|
+
async dropIndex(bucketName, indexName, options, callback) {
|
|
178
|
+
if (options instanceof Function) {
|
|
179
|
+
callback = arguments[2];
|
|
180
|
+
options = undefined;
|
|
181
|
+
}
|
|
182
|
+
if (!options) {
|
|
183
|
+
options = {};
|
|
184
|
+
}
|
|
185
|
+
return this._dropIndex(bucketName, {
|
|
186
|
+
name: indexName,
|
|
187
|
+
ignoreIfNotExists: options.ignoreIfNotExists,
|
|
188
|
+
parentSpan: options.parentSpan,
|
|
189
|
+
timeout: options.timeout,
|
|
190
|
+
}, callback);
|
|
210
191
|
}
|
|
211
192
|
/**
|
|
212
193
|
* Drops an existing primary index.
|
|
@@ -215,22 +196,20 @@ class QueryIndexManager {
|
|
|
215
196
|
* @param options Optional parameters for this operation.
|
|
216
197
|
* @param callback A node-style callback to be invoked after execution.
|
|
217
198
|
*/
|
|
218
|
-
dropPrimaryIndex(bucketName, options, callback) {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
}, callback);
|
|
233
|
-
});
|
|
199
|
+
async dropPrimaryIndex(bucketName, options, callback) {
|
|
200
|
+
if (options instanceof Function) {
|
|
201
|
+
callback = arguments[1];
|
|
202
|
+
options = undefined;
|
|
203
|
+
}
|
|
204
|
+
if (!options) {
|
|
205
|
+
options = {};
|
|
206
|
+
}
|
|
207
|
+
return this._dropIndex(bucketName, {
|
|
208
|
+
name: options.name,
|
|
209
|
+
ignoreIfNotExists: options.ignoreIfNotExists,
|
|
210
|
+
parentSpan: options.parentSpan,
|
|
211
|
+
timeout: options.timeout,
|
|
212
|
+
}, callback);
|
|
234
213
|
}
|
|
235
214
|
/**
|
|
236
215
|
* Returns a list of indexes for a specific bucket.
|
|
@@ -239,40 +218,38 @@ class QueryIndexManager {
|
|
|
239
218
|
* @param options Optional parameters for this operation.
|
|
240
219
|
* @param callback A node-style callback to be invoked after execution.
|
|
241
220
|
*/
|
|
242
|
-
getAllIndexes(bucketName, options, callback) {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
const qs = `SELECT idx.* FROM system:indexes AS idx
|
|
221
|
+
async getAllIndexes(bucketName, options, callback) {
|
|
222
|
+
if (options instanceof Function) {
|
|
223
|
+
callback = arguments[1];
|
|
224
|
+
options = undefined;
|
|
225
|
+
}
|
|
226
|
+
if (!options) {
|
|
227
|
+
options = {};
|
|
228
|
+
}
|
|
229
|
+
const qs = `SELECT idx.* FROM system:indexes AS idx
|
|
252
230
|
WHERE (
|
|
253
231
|
(\`bucket_id\` IS MISSING AND \`keyspace_id\`="${bucketName}")
|
|
254
232
|
OR \`bucket_id\`="${bucketName}"
|
|
255
233
|
) AND \`using\`="gsi" ORDER BY is_primary DESC, name ASC`;
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
});
|
|
234
|
+
const parentSpan = options.parentSpan;
|
|
235
|
+
const timeout = options.timeout;
|
|
236
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
237
|
+
const res = await this._cluster.query(qs, {
|
|
238
|
+
parentSpan: parentSpan,
|
|
239
|
+
timeout: timeout,
|
|
240
|
+
});
|
|
241
|
+
const indexes = res.rows.map((row) => new QueryIndex({
|
|
242
|
+
name: row.name,
|
|
243
|
+
isPrimary: row.is_primary,
|
|
244
|
+
type: row.using,
|
|
245
|
+
state: row.state,
|
|
246
|
+
keyspace: row.keyspace_id,
|
|
247
|
+
indexKey: row.index_key,
|
|
248
|
+
condition: row.condition,
|
|
249
|
+
partition: row.partition,
|
|
250
|
+
}));
|
|
251
|
+
return indexes;
|
|
252
|
+
}, callback);
|
|
276
253
|
}
|
|
277
254
|
/**
|
|
278
255
|
* Starts building any indexes which were previously created with deferred=true.
|
|
@@ -281,49 +258,47 @@ class QueryIndexManager {
|
|
|
281
258
|
* @param options Optional parameters for this operation.
|
|
282
259
|
* @param callback A node-style callback to be invoked after execution.
|
|
283
260
|
*/
|
|
284
|
-
buildDeferredIndexes(bucketName, options, callback) {
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
261
|
+
async buildDeferredIndexes(bucketName, options, callback) {
|
|
262
|
+
if (options instanceof Function) {
|
|
263
|
+
callback = arguments[1];
|
|
264
|
+
options = undefined;
|
|
265
|
+
}
|
|
266
|
+
if (!options) {
|
|
267
|
+
options = {};
|
|
268
|
+
}
|
|
269
|
+
const parentSpan = options.parentSpan;
|
|
270
|
+
const timeout = options.timeout;
|
|
271
|
+
const timer = new utilities_1.CompoundTimeout(timeout);
|
|
272
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
273
|
+
const indexes = await this.getAllIndexes(bucketName, {
|
|
274
|
+
parentSpan: parentSpan,
|
|
275
|
+
timeout: timer.left(),
|
|
276
|
+
});
|
|
277
|
+
// Filter out the index names that need to be built
|
|
278
|
+
const deferredList = indexes
|
|
279
|
+
.filter((index) => index.state === 'deferred' || index.state === 'pending')
|
|
280
|
+
.map((index) => index.name);
|
|
281
|
+
// If there are no deferred indexes, we have nothing to do.
|
|
282
|
+
if (deferredList.length === 0) {
|
|
283
|
+
return [];
|
|
292
284
|
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
timeout: timer.left(),
|
|
300
|
-
});
|
|
301
|
-
// Filter out the index names that need to be built
|
|
302
|
-
const deferredList = indexes
|
|
303
|
-
.filter((index) => index.state === 'deferred' || index.state === 'pending')
|
|
304
|
-
.map((index) => index.name);
|
|
305
|
-
// If there are no deferred indexes, we have nothing to do.
|
|
306
|
-
if (deferredList.length === 0) {
|
|
307
|
-
return [];
|
|
308
|
-
}
|
|
309
|
-
let qs = '';
|
|
310
|
-
qs += 'BUILD INDEX ON `' + bucketName + '` ';
|
|
311
|
-
qs += '(';
|
|
312
|
-
for (let j = 0; j < deferredList.length; ++j) {
|
|
313
|
-
if (j > 0) {
|
|
314
|
-
qs += ', ';
|
|
315
|
-
}
|
|
316
|
-
qs += '`' + deferredList[j] + '`';
|
|
285
|
+
let qs = '';
|
|
286
|
+
qs += 'BUILD INDEX ON `' + bucketName + '` ';
|
|
287
|
+
qs += '(';
|
|
288
|
+
for (let j = 0; j < deferredList.length; ++j) {
|
|
289
|
+
if (j > 0) {
|
|
290
|
+
qs += ', ';
|
|
317
291
|
}
|
|
318
|
-
qs += '
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
292
|
+
qs += '`' + deferredList[j] + '`';
|
|
293
|
+
}
|
|
294
|
+
qs += ')';
|
|
295
|
+
// Run our deferred build query
|
|
296
|
+
await this._cluster.query(qs, {
|
|
297
|
+
timeout: timer.left(),
|
|
298
|
+
});
|
|
299
|
+
// Return the list of indices that we built
|
|
300
|
+
return deferredList;
|
|
301
|
+
}, callback);
|
|
327
302
|
}
|
|
328
303
|
/**
|
|
329
304
|
* Waits for a number of indexes to finish creation and be ready to use.
|
|
@@ -334,54 +309,52 @@ class QueryIndexManager {
|
|
|
334
309
|
* @param options Optional parameters for this operation.
|
|
335
310
|
* @param callback A node-style callback to be invoked after execution.
|
|
336
311
|
*/
|
|
337
|
-
watchIndexes(bucketName, indexNames, timeout, options, callback) {
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
break;
|
|
369
|
-
}
|
|
370
|
-
// Add 500 to our interval to a max of 1000
|
|
371
|
-
curInterval = Math.min(1000, curInterval + 500);
|
|
372
|
-
// Make sure we don't go past our user-specified duration
|
|
373
|
-
const userTimeLeft = timer.left();
|
|
374
|
-
if (userTimeLeft !== undefined) {
|
|
375
|
-
curInterval = Math.min(curInterval, userTimeLeft);
|
|
376
|
-
}
|
|
377
|
-
if (curInterval <= 0) {
|
|
378
|
-
throw new errors_1.CouchbaseError('Failed to find all indexes online within the alloted time.');
|
|
379
|
-
}
|
|
380
|
-
// Wait until curInterval expires
|
|
381
|
-
yield new Promise((resolve) => setTimeout(() => resolve(true), curInterval));
|
|
312
|
+
async watchIndexes(bucketName, indexNames, timeout, options, callback) {
|
|
313
|
+
if (options instanceof Function) {
|
|
314
|
+
callback = arguments[3];
|
|
315
|
+
options = undefined;
|
|
316
|
+
}
|
|
317
|
+
if (!options) {
|
|
318
|
+
options = {};
|
|
319
|
+
}
|
|
320
|
+
if (options.watchPrimary) {
|
|
321
|
+
indexNames = [...indexNames, '#primary'];
|
|
322
|
+
}
|
|
323
|
+
const parentSpan = options.parentSpan;
|
|
324
|
+
const timer = new utilities_1.CompoundTimeout(timeout);
|
|
325
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
326
|
+
let curInterval = 50;
|
|
327
|
+
for (;;) {
|
|
328
|
+
// Get all the indexes that are currently registered
|
|
329
|
+
const foundIdxs = await this.getAllIndexes(bucketName, {
|
|
330
|
+
parentSpan: parentSpan,
|
|
331
|
+
timeout: timer.left(),
|
|
332
|
+
});
|
|
333
|
+
const onlineIdxs = foundIdxs.filter((idx) => idx.state === 'online');
|
|
334
|
+
const onlineIdxNames = onlineIdxs.map((idx) => idx.name);
|
|
335
|
+
// Check if all the indexes we want are online
|
|
336
|
+
let allOnline = true;
|
|
337
|
+
indexNames.forEach((indexName) => {
|
|
338
|
+
allOnline = allOnline && onlineIdxNames.indexOf(indexName) !== -1;
|
|
339
|
+
});
|
|
340
|
+
// If all the indexes are online, we've succeeded
|
|
341
|
+
if (allOnline) {
|
|
342
|
+
break;
|
|
382
343
|
}
|
|
383
|
-
|
|
384
|
-
|
|
344
|
+
// Add 500 to our interval to a max of 1000
|
|
345
|
+
curInterval = Math.min(1000, curInterval + 500);
|
|
346
|
+
// Make sure we don't go past our user-specified duration
|
|
347
|
+
const userTimeLeft = timer.left();
|
|
348
|
+
if (userTimeLeft !== undefined) {
|
|
349
|
+
curInterval = Math.min(curInterval, userTimeLeft);
|
|
350
|
+
}
|
|
351
|
+
if (curInterval <= 0) {
|
|
352
|
+
throw new errors_1.CouchbaseError('Failed to find all indexes online within the alloted time.');
|
|
353
|
+
}
|
|
354
|
+
// Wait until curInterval expires
|
|
355
|
+
await new Promise((resolve) => setTimeout(() => resolve(true), curInterval));
|
|
356
|
+
}
|
|
357
|
+
}, callback);
|
|
385
358
|
}
|
|
386
359
|
}
|
|
387
360
|
exports.QueryIndexManager = QueryIndexManager;
|
package/dist/scope.js
CHANGED
|
@@ -76,7 +76,10 @@ class Scope {
|
|
|
76
76
|
const bucket = this.bucket;
|
|
77
77
|
const exec = new queryexecutor_1.QueryExecutor(bucket.conn);
|
|
78
78
|
const options_ = options;
|
|
79
|
-
return utilities_1.PromiseHelper.wrapAsync(() => exec.query(statement,
|
|
79
|
+
return utilities_1.PromiseHelper.wrapAsync(() => exec.query(statement, {
|
|
80
|
+
...options_,
|
|
81
|
+
queryContext: `${bucket.name}.${this.name}`,
|
|
82
|
+
}), callback);
|
|
80
83
|
}
|
|
81
84
|
/**
|
|
82
85
|
* Executes an analytics query against the cluster scoped this scope.
|
|
@@ -96,7 +99,10 @@ class Scope {
|
|
|
96
99
|
const bucket = this.bucket;
|
|
97
100
|
const exec = new analyticsexecutor_1.AnalyticsExecutor(bucket.conn);
|
|
98
101
|
const options_ = options;
|
|
99
|
-
return utilities_1.PromiseHelper.wrapAsync(() => exec.query(statement,
|
|
102
|
+
return utilities_1.PromiseHelper.wrapAsync(() => exec.query(statement, {
|
|
103
|
+
...options_,
|
|
104
|
+
queryContext: `${bucket.name}.${this.name}`,
|
|
105
|
+
}), callback);
|
|
100
106
|
}
|
|
101
107
|
}
|
|
102
108
|
exports.Scope = Scope;
|
package/dist/searchexecutor.js
CHANGED
|
@@ -50,6 +50,9 @@ class SearchExecutor {
|
|
|
50
50
|
if (options.disableScoring) {
|
|
51
51
|
queryObj.score = 'none';
|
|
52
52
|
}
|
|
53
|
+
if (options.includeLocations !== undefined) {
|
|
54
|
+
queryObj.includeLocations = options.includeLocations;
|
|
55
|
+
}
|
|
53
56
|
if (options.consistency) {
|
|
54
57
|
queryObjCtl.consistency = {
|
|
55
58
|
level: options.consistency,
|