@mongosh/shell-api 2.1.1 → 2.1.4
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/AUTHORS +1 -0
- package/lib/abstract-cursor.js +176 -132
- package/lib/abstract-cursor.js.map +1 -1
- package/lib/aggregate-or-find-cursor.js +102 -51
- package/lib/aggregate-or-find-cursor.js.map +1 -1
- package/lib/aggregation-cursor.js +59 -13
- package/lib/aggregation-cursor.js.map +1 -1
- package/lib/bulk.js +248 -197
- package/lib/bulk.js.map +1 -1
- package/lib/change-stream-cursor.js +145 -101
- package/lib/change-stream-cursor.js.map +1 -1
- package/lib/collection.d.ts +2 -1
- package/lib/collection.js +1185 -1245
- package/lib/collection.js.map +1 -1
- package/lib/cursor.js +238 -203
- package/lib/cursor.js.map +1 -1
- package/lib/database.js +1189 -1206
- package/lib/database.js.map +1 -1
- package/lib/dbquery.js +68 -22
- package/lib/dbquery.js.map +1 -1
- package/lib/decorators.d.ts +39 -13
- package/lib/decorators.js +34 -34
- package/lib/decorators.js.map +1 -1
- package/lib/explainable-cursor.js +66 -20
- package/lib/explainable-cursor.js.map +1 -1
- package/lib/explainable.js +214 -179
- package/lib/explainable.js.map +1 -1
- package/lib/field-level-encryption.js +286 -235
- package/lib/field-level-encryption.js.map +1 -1
- package/lib/helpers.d.ts +9 -1
- package/lib/helpers.js +24 -17
- package/lib/helpers.js.map +1 -1
- package/lib/interruptor.js.map +1 -1
- package/lib/log-entry.js.map +1 -1
- package/lib/mongo-errors.js +3 -1
- package/lib/mongo-errors.js.map +1 -1
- package/lib/mongo.js +581 -547
- package/lib/mongo.js.map +1 -1
- package/lib/plan-cache.js +108 -64
- package/lib/plan-cache.js.map +1 -1
- package/lib/replica-set.js +290 -277
- package/lib/replica-set.js.map +1 -1
- package/lib/result.js +228 -91
- package/lib/result.js.map +1 -1
- package/lib/run-command-cursor.js +59 -13
- package/lib/run-command-cursor.js.map +1 -1
- package/lib/session.js +123 -76
- package/lib/session.js.map +1 -1
- package/lib/shard.js +507 -514
- package/lib/shard.js.map +1 -1
- package/lib/shell-api.js +313 -268
- package/lib/shell-api.js.map +1 -1
- package/lib/shell-bson.js.map +1 -1
- package/lib/shell-instance-state.js.map +1 -1
- package/lib/stream-processor.js +139 -92
- package/lib/stream-processor.js.map +1 -1
- package/lib/streams.js +158 -110
- package/lib/streams.js.map +1 -1
- package/package.json +10 -10
package/lib/database.js
CHANGED
|
@@ -1,9 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
3
|
+
var useValue = arguments.length > 2;
|
|
4
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
5
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
6
|
+
}
|
|
7
|
+
return useValue ? value : void 0;
|
|
8
|
+
};
|
|
9
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
10
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
11
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
12
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
13
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
14
|
+
var _, done = false;
|
|
15
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
16
|
+
var context = {};
|
|
17
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
18
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
19
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
20
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
21
|
+
if (kind === "accessor") {
|
|
22
|
+
if (result === void 0) continue;
|
|
23
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
24
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
25
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
26
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
27
|
+
}
|
|
28
|
+
else if (_ = accept(result)) {
|
|
29
|
+
if (kind === "field") initializers.unshift(_);
|
|
30
|
+
else descriptor[key] = _;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
34
|
+
done = true;
|
|
35
|
+
};
|
|
36
|
+
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
|
37
|
+
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
38
|
+
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
7
39
|
};
|
|
8
40
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
41
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
@@ -18,1277 +50,1228 @@ const errors_1 = require("@mongosh/errors");
|
|
|
18
50
|
const history_1 = require("@mongosh/history");
|
|
19
51
|
const change_stream_cursor_1 = __importDefault(require("./change-stream-cursor"));
|
|
20
52
|
const error_codes_1 = require("./error-codes");
|
|
21
|
-
let Database =
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
+
let Database = (() => {
|
|
54
|
+
let _classDecorators = [decorators_1.shellApiClassDefault];
|
|
55
|
+
let _classDescriptor;
|
|
56
|
+
let _classExtraInitializers = [];
|
|
57
|
+
let _classThis;
|
|
58
|
+
let _classSuper = decorators_1.ShellApiWithMongoClass;
|
|
59
|
+
let _instanceExtraInitializers = [];
|
|
60
|
+
let _getMongo_decorators;
|
|
61
|
+
let _getCollectionNames_decorators;
|
|
62
|
+
let _getCollectionInfos_decorators;
|
|
63
|
+
let _runCommand_decorators;
|
|
64
|
+
let _adminCommand_decorators;
|
|
65
|
+
let _aggregate_decorators;
|
|
66
|
+
let _getSiblingDB_decorators;
|
|
67
|
+
let _getCollection_decorators;
|
|
68
|
+
let _dropDatabase_decorators;
|
|
69
|
+
let _createUser_decorators;
|
|
70
|
+
let _updateUser_decorators;
|
|
71
|
+
let _changeUserPassword_decorators;
|
|
72
|
+
let _logout_decorators;
|
|
73
|
+
let _dropUser_decorators;
|
|
74
|
+
let _dropAllUsers_decorators;
|
|
75
|
+
let _auth_decorators;
|
|
76
|
+
let _grantRolesToUser_decorators;
|
|
77
|
+
let _revokeRolesFromUser_decorators;
|
|
78
|
+
let _getUser_decorators;
|
|
79
|
+
let _getUsers_decorators;
|
|
80
|
+
let _createCollection_decorators;
|
|
81
|
+
let _createEncryptedCollection_decorators;
|
|
82
|
+
let _createView_decorators;
|
|
83
|
+
let _createRole_decorators;
|
|
84
|
+
let _updateRole_decorators;
|
|
85
|
+
let _dropRole_decorators;
|
|
86
|
+
let _dropAllRoles_decorators;
|
|
87
|
+
let _grantRolesToRole_decorators;
|
|
88
|
+
let _revokeRolesFromRole_decorators;
|
|
89
|
+
let _grantPrivilegesToRole_decorators;
|
|
90
|
+
let _revokePrivilegesFromRole_decorators;
|
|
91
|
+
let _getRole_decorators;
|
|
92
|
+
let _getRoles_decorators;
|
|
93
|
+
let _currentOp_decorators;
|
|
94
|
+
let _killOp_decorators;
|
|
95
|
+
let _shutdownServer_decorators;
|
|
96
|
+
let _fsyncLock_decorators;
|
|
97
|
+
let _fsyncUnlock_decorators;
|
|
98
|
+
let _version_decorators;
|
|
99
|
+
let _serverBits_decorators;
|
|
100
|
+
let _isMaster_decorators;
|
|
101
|
+
let _hello_decorators;
|
|
102
|
+
let _serverBuildInfo_decorators;
|
|
103
|
+
let _serverStatus_decorators;
|
|
104
|
+
let _stats_decorators;
|
|
105
|
+
let _hostInfo_decorators;
|
|
106
|
+
let _serverCmdLineOpts_decorators;
|
|
107
|
+
let _rotateCertificates_decorators;
|
|
108
|
+
let _printCollectionStats_decorators;
|
|
109
|
+
let _getProfilingStatus_decorators;
|
|
110
|
+
let _setProfilingLevel_decorators;
|
|
111
|
+
let _setLogLevel_decorators;
|
|
112
|
+
let _getLogComponents_decorators;
|
|
113
|
+
let _cloneDatabase_decorators;
|
|
114
|
+
let _cloneCollection_decorators;
|
|
115
|
+
let _copyDatabase_decorators;
|
|
116
|
+
let _commandHelp_decorators;
|
|
117
|
+
let _listCommands_decorators;
|
|
118
|
+
let _getLastErrorObj_decorators;
|
|
119
|
+
let _getLastError_decorators;
|
|
120
|
+
let _printShardingStatus_decorators;
|
|
121
|
+
let _printSecondaryReplicationInfo_decorators;
|
|
122
|
+
let _getReplicationInfo_decorators;
|
|
123
|
+
let _printReplicationInfo_decorators;
|
|
124
|
+
let _printSlaveReplicationInfo_decorators;
|
|
125
|
+
let _setSecondaryOk_decorators;
|
|
126
|
+
let _watch_decorators;
|
|
127
|
+
let _sql_decorators;
|
|
128
|
+
let _checkMetadataConsistency_decorators;
|
|
129
|
+
var Database = _classThis = class extends _classSuper {
|
|
130
|
+
constructor(mongo, name, session) {
|
|
131
|
+
super();
|
|
132
|
+
this._mongo = (__runInitializers(this, _instanceExtraInitializers), void 0);
|
|
133
|
+
this._cachedCollectionNames = [];
|
|
134
|
+
this._cachedHello = null;
|
|
135
|
+
this._mongo = mongo;
|
|
136
|
+
this._name = name;
|
|
137
|
+
const collections = Object.create(null);
|
|
138
|
+
this._collections = collections;
|
|
139
|
+
this._session = session;
|
|
140
|
+
const proxy = new Proxy(this, {
|
|
141
|
+
get: (target, prop) => {
|
|
142
|
+
if (prop in target) {
|
|
143
|
+
return target[prop];
|
|
144
|
+
}
|
|
145
|
+
if (typeof prop !== 'string' ||
|
|
146
|
+
prop.startsWith('_') ||
|
|
147
|
+
!(0, helpers_1.isValidCollectionName)(prop)) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
if (!collections[prop]) {
|
|
151
|
+
collections[prop] = new collection_1.default(mongo, proxy, prop);
|
|
152
|
+
}
|
|
153
|
+
return collections[prop];
|
|
154
|
+
},
|
|
155
|
+
});
|
|
156
|
+
return proxy;
|
|
53
157
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
158
|
+
async _baseOptions() {
|
|
159
|
+
const options = {};
|
|
160
|
+
if (this._session) {
|
|
161
|
+
options.session = this._session._session;
|
|
162
|
+
}
|
|
163
|
+
const maxTimeMS = await this._instanceState.shellApi.config.get('maxTimeMS');
|
|
164
|
+
if (typeof maxTimeMS === 'number') {
|
|
165
|
+
options.maxTimeMS = maxTimeMS;
|
|
166
|
+
}
|
|
167
|
+
return options;
|
|
57
168
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
var _a;
|
|
62
|
-
return (_a = this._cachedHello) !== null && _a !== void 0 ? _a : (await this.hello());
|
|
63
|
-
}
|
|
64
|
-
[enums_1.asPrintable]() {
|
|
65
|
-
return this._name;
|
|
66
|
-
}
|
|
67
|
-
_emitDatabaseApiCall(methodName, methodArguments = {}) {
|
|
68
|
-
this._mongo._instanceState.emitApiCallWithArgs({
|
|
69
|
-
method: methodName,
|
|
70
|
-
class: 'Database',
|
|
71
|
-
db: this._name,
|
|
72
|
-
arguments: methodArguments,
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
async _runCommand(cmd, options = {}) {
|
|
76
|
-
return this._mongo._serviceProvider.runCommandWithCheck(this._name, (0, helpers_1.adjustRunCommand)(cmd, this._instanceState.shellBson), {
|
|
77
|
-
...(await this._baseOptions()),
|
|
78
|
-
...options,
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
async _runReadCommand(cmd, options = {}) {
|
|
82
|
-
return this._mongo._serviceProvider.runCommandWithCheck(this._name, (0, helpers_1.adjustRunCommand)(cmd, this._instanceState.shellBson), {
|
|
83
|
-
...this._mongo._getExplicitlyRequestedReadPref(),
|
|
84
|
-
...(await this._baseOptions()),
|
|
85
|
-
...options,
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
async _runAdminCommand(cmd, options = {}) {
|
|
89
|
-
return this.getSiblingDB('admin')._runCommand(cmd, {
|
|
90
|
-
...(await this._baseOptions()),
|
|
91
|
-
...options,
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
async _runCursorCommand(cmd, options = {}) {
|
|
95
|
-
const providerCursor = this._mongo._serviceProvider.runCursorCommand(this._name, (0, helpers_1.adjustRunCommand)(cmd, this._instanceState.shellBson), {
|
|
96
|
-
...this._mongo._getExplicitlyRequestedReadPref(),
|
|
97
|
-
...(await this._baseOptions()),
|
|
98
|
-
...options,
|
|
99
|
-
});
|
|
100
|
-
const cursor = new index_1.RunCommandCursor(this._mongo, providerCursor);
|
|
101
|
-
this._mongo._instanceState.currentCursor = cursor;
|
|
102
|
-
return cursor;
|
|
103
|
-
}
|
|
104
|
-
async _runAdminCursorCommand(cmd, options = {}) {
|
|
105
|
-
return this.getSiblingDB('admin')._runCursorCommand(cmd, options);
|
|
106
|
-
}
|
|
107
|
-
async _listCollections(filter, options) {
|
|
108
|
-
return ((await this._mongo._serviceProvider.listCollections(this._name, filter, {
|
|
109
|
-
...this._mongo._getExplicitlyRequestedReadPref(),
|
|
110
|
-
...(await this._baseOptions()),
|
|
111
|
-
...options,
|
|
112
|
-
})) || []);
|
|
113
|
-
}
|
|
114
|
-
async _getCollectionNames(options) {
|
|
115
|
-
const infos = await this._listCollections({}, { ...options, nameOnly: true });
|
|
116
|
-
this._cachedCollectionNames = infos.map((collection) => collection.name);
|
|
117
|
-
return this._cachedCollectionNames;
|
|
118
|
-
}
|
|
119
|
-
async _getCollectionNamesWithTypes(options) {
|
|
120
|
-
let collections = await this._listCollections({}, { ...options, nameOnly: true });
|
|
121
|
-
collections = collections.sort((c1, c2) => c1.name.localeCompare(c2.name));
|
|
122
|
-
this._cachedCollectionNames = collections.map((collection) => collection.name);
|
|
123
|
-
return collections.map((collection, index) => ({
|
|
124
|
-
name: collection.name,
|
|
125
|
-
badge: (0, helpers_1.getBadge)(collections, index),
|
|
126
|
-
}));
|
|
127
|
-
}
|
|
128
|
-
async _getCollectionNamesForCompletion() {
|
|
129
|
-
return await Promise.race([
|
|
130
|
-
(async () => {
|
|
131
|
-
return await this._getCollectionNames({
|
|
132
|
-
readPreference: 'primaryPreferred',
|
|
133
|
-
});
|
|
134
|
-
})(),
|
|
135
|
-
(async () => {
|
|
136
|
-
await new Promise((resolve) => setTimeout(resolve, 200).unref());
|
|
137
|
-
return this._cachedCollectionNames;
|
|
138
|
-
})(),
|
|
139
|
-
]);
|
|
140
|
-
}
|
|
141
|
-
async _getLastErrorObj(w, wTimeout, j) {
|
|
142
|
-
const cmd = { getlasterror: 1 };
|
|
143
|
-
if (w) {
|
|
144
|
-
cmd.w = w;
|
|
169
|
+
async _maybeCachedHello() {
|
|
170
|
+
var _a;
|
|
171
|
+
return (_a = this._cachedHello) !== null && _a !== void 0 ? _a : (await this.hello());
|
|
145
172
|
}
|
|
146
|
-
|
|
147
|
-
|
|
173
|
+
[enums_1.asPrintable]() {
|
|
174
|
+
return this._name;
|
|
148
175
|
}
|
|
149
|
-
|
|
150
|
-
|
|
176
|
+
_emitDatabaseApiCall(methodName, methodArguments = {}) {
|
|
177
|
+
this._mongo._instanceState.emitApiCallWithArgs({
|
|
178
|
+
method: methodName,
|
|
179
|
+
class: 'Database',
|
|
180
|
+
db: this._name,
|
|
181
|
+
arguments: methodArguments,
|
|
182
|
+
});
|
|
151
183
|
}
|
|
152
|
-
|
|
153
|
-
return
|
|
184
|
+
async _runCommand(cmd, options = {}) {
|
|
185
|
+
return this._mongo._serviceProvider.runCommandWithCheck(this._name, (0, helpers_1.adjustRunCommand)(cmd, this._instanceState.shellBson), {
|
|
186
|
+
...(await this._baseOptions()),
|
|
187
|
+
...options,
|
|
188
|
+
});
|
|
154
189
|
}
|
|
155
|
-
|
|
156
|
-
return
|
|
190
|
+
async _runReadCommand(cmd, options = {}) {
|
|
191
|
+
return this._mongo._serviceProvider.runCommandWithCheck(this._name, (0, helpers_1.adjustRunCommand)(cmd, this._instanceState.shellBson), {
|
|
192
|
+
...this._mongo._getExplicitlyRequestedReadPref(),
|
|
193
|
+
...(await this._baseOptions()),
|
|
194
|
+
...options,
|
|
195
|
+
});
|
|
157
196
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
return this._name;
|
|
164
|
-
}
|
|
165
|
-
async getCollectionNames() {
|
|
166
|
-
this._emitDatabaseApiCall('getCollectionNames');
|
|
167
|
-
return this._getCollectionNames();
|
|
168
|
-
}
|
|
169
|
-
async getCollectionInfos(filter = {}, options = {}) {
|
|
170
|
-
this._emitDatabaseApiCall('getCollectionInfos', { filter, options });
|
|
171
|
-
return await this._listCollections(filter, options);
|
|
172
|
-
}
|
|
173
|
-
async runCommand(cmd, options) {
|
|
174
|
-
(0, helpers_1.assertArgsDefinedType)([cmd], [['string', 'object']], 'Database.runCommand');
|
|
175
|
-
if (typeof cmd === 'string') {
|
|
176
|
-
cmd = { [cmd]: 1 };
|
|
197
|
+
async _runAdminCommand(cmd, options = {}) {
|
|
198
|
+
return this.getSiblingDB('admin')._runCommand(cmd, {
|
|
199
|
+
...(await this._baseOptions()),
|
|
200
|
+
...options,
|
|
201
|
+
});
|
|
177
202
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
203
|
+
async _runCursorCommand(cmd, options = {}) {
|
|
204
|
+
const providerCursor = this._mongo._serviceProvider.runCursorCommand(this._name, (0, helpers_1.adjustRunCommand)(cmd, this._instanceState.shellBson), {
|
|
205
|
+
...this._mongo._getExplicitlyRequestedReadPref(),
|
|
206
|
+
...(await this._baseOptions()),
|
|
207
|
+
...options,
|
|
208
|
+
});
|
|
209
|
+
const cursor = new index_1.RunCommandCursor(this._mongo, providerCursor);
|
|
210
|
+
this._mongo._instanceState.currentCursor = cursor;
|
|
211
|
+
return cursor;
|
|
212
|
+
}
|
|
213
|
+
async _runAdminCursorCommand(cmd, options = {}) {
|
|
214
|
+
return this.getSiblingDB('admin')._runCursorCommand(cmd, options);
|
|
215
|
+
}
|
|
216
|
+
async _listCollections(filter, options) {
|
|
217
|
+
return ((await this._mongo._serviceProvider.listCollections(this._name, filter, {
|
|
218
|
+
...this._mongo._getExplicitlyRequestedReadPref(),
|
|
219
|
+
...(await this._baseOptions()),
|
|
220
|
+
...options,
|
|
221
|
+
})) || []);
|
|
222
|
+
}
|
|
223
|
+
async _getCollectionNames(options) {
|
|
224
|
+
const infos = await this._listCollections({}, { ...options, nameOnly: true });
|
|
225
|
+
this._cachedCollectionNames = infos.map((collection) => collection.name);
|
|
226
|
+
return this._cachedCollectionNames;
|
|
227
|
+
}
|
|
228
|
+
async _getCollectionNamesWithTypes(options) {
|
|
229
|
+
let collections = await this._listCollections({}, { ...options, nameOnly: true });
|
|
230
|
+
collections = collections.sort((c1, c2) => c1.name.localeCompare(c2.name));
|
|
231
|
+
this._cachedCollectionNames = collections.map((collection) => collection.name);
|
|
232
|
+
return collections.map((collection, index) => ({
|
|
233
|
+
name: collection.name,
|
|
234
|
+
badge: (0, helpers_1.getBadge)(collections, index),
|
|
235
|
+
}));
|
|
236
|
+
}
|
|
237
|
+
async _getCollectionNamesForCompletion() {
|
|
238
|
+
return await Promise.race([
|
|
239
|
+
(async () => {
|
|
240
|
+
return await this._getCollectionNames({
|
|
241
|
+
readPreference: 'primaryPreferred',
|
|
242
|
+
});
|
|
243
|
+
})(),
|
|
244
|
+
(async () => {
|
|
245
|
+
await new Promise((resolve) => setTimeout(resolve, 200).unref());
|
|
246
|
+
return this._cachedCollectionNames;
|
|
247
|
+
})(),
|
|
248
|
+
]);
|
|
249
|
+
}
|
|
250
|
+
async _getLastErrorObj(w, wTimeout, j) {
|
|
251
|
+
const cmd = { getlasterror: 1 };
|
|
252
|
+
if (w) {
|
|
253
|
+
cmd.w = w;
|
|
254
|
+
}
|
|
255
|
+
if (wTimeout) {
|
|
256
|
+
cmd.wtimeout = wTimeout;
|
|
257
|
+
}
|
|
258
|
+
if (j !== undefined) {
|
|
259
|
+
cmd.j = j;
|
|
260
|
+
}
|
|
261
|
+
try {
|
|
262
|
+
return await this._mongo._serviceProvider.runCommand(this._name, cmd, await this._baseOptions());
|
|
263
|
+
}
|
|
264
|
+
catch (e) {
|
|
265
|
+
return e;
|
|
266
|
+
}
|
|
181
267
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
async adminCommand(cmd) {
|
|
185
|
-
(0, helpers_1.assertArgsDefinedType)([cmd], [['string', 'object']], 'Database.adminCommand');
|
|
186
|
-
if (typeof cmd === 'string') {
|
|
187
|
-
cmd = { [cmd]: 1 };
|
|
268
|
+
getMongo() {
|
|
269
|
+
return this._mongo;
|
|
188
270
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
this._emitDatabaseApiCall('adminCommand', { cmd });
|
|
271
|
+
getName() {
|
|
272
|
+
return this._name;
|
|
192
273
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
(0, helpers_1.assertArgsDefinedType)([pipeline], [true], 'Database.aggregate');
|
|
197
|
-
this._emitDatabaseApiCall('aggregate', { options, pipeline });
|
|
198
|
-
const { aggOptions, dbOptions, explain } = (0, helpers_1.adaptAggregateOptions)(options);
|
|
199
|
-
const providerCursor = this._mongo._serviceProvider.aggregateDb(this._name, pipeline, { ...(await this._baseOptions()), ...aggOptions }, dbOptions);
|
|
200
|
-
const cursor = new index_1.AggregationCursor(this._mongo, providerCursor);
|
|
201
|
-
if (explain) {
|
|
202
|
-
return await cursor.explain(explain);
|
|
203
|
-
}
|
|
204
|
-
else if ((0, helpers_1.shouldRunAggregationImmediately)(pipeline)) {
|
|
205
|
-
await cursor.hasNext();
|
|
206
|
-
}
|
|
207
|
-
this._mongo._instanceState.currentCursor = cursor;
|
|
208
|
-
return cursor;
|
|
209
|
-
}
|
|
210
|
-
getSiblingDB(db) {
|
|
211
|
-
(0, helpers_1.assertArgsDefinedType)([db], ['string'], 'Database.getSiblingDB');
|
|
212
|
-
this._emitDatabaseApiCall('getSiblingDB', { db });
|
|
213
|
-
if (this._session) {
|
|
214
|
-
return this._session.getDatabase(db);
|
|
274
|
+
async getCollectionNames() {
|
|
275
|
+
this._emitDatabaseApiCall('getCollectionNames');
|
|
276
|
+
return this._getCollectionNames();
|
|
215
277
|
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
(0, helpers_1.assertArgsDefinedType)([coll], ['string'], 'Database.getColl');
|
|
220
|
-
this._emitDatabaseApiCall('getCollection', { coll });
|
|
221
|
-
if (!(0, helpers_1.isValidCollectionName)(coll)) {
|
|
222
|
-
throw new errors_1.MongoshInvalidInputError(`Invalid collection name: ${coll}`, errors_1.CommonErrors.InvalidArgument);
|
|
278
|
+
async getCollectionInfos(filter = {}, options = {}) {
|
|
279
|
+
this._emitDatabaseApiCall('getCollectionInfos', { filter, options });
|
|
280
|
+
return await this._listCollections(filter, options);
|
|
223
281
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
282
|
+
async runCommand(cmd, options) {
|
|
283
|
+
(0, helpers_1.assertArgsDefinedType)([cmd], [['string', 'object']], 'Database.runCommand');
|
|
284
|
+
if (typeof cmd === 'string') {
|
|
285
|
+
cmd = { [cmd]: 1 };
|
|
286
|
+
}
|
|
287
|
+
try {
|
|
288
|
+
const hiddenCommands = new RegExp(history_1.HIDDEN_COMMANDS);
|
|
289
|
+
if (!Object.keys(cmd).some((k) => hiddenCommands.test(k))) {
|
|
290
|
+
this._emitDatabaseApiCall('runCommand', { cmd, options });
|
|
291
|
+
}
|
|
292
|
+
return await this._runCommand(cmd, options);
|
|
293
|
+
}
|
|
294
|
+
catch (error) {
|
|
295
|
+
if (error.codeName === 'NotPrimaryNoSecondaryOk') {
|
|
296
|
+
const message = `not primary - consider passing the readPreference option e.g. db.runCommand({ command }, { readPreference: "secondaryPreferred" })`;
|
|
297
|
+
error.message = message;
|
|
298
|
+
}
|
|
299
|
+
throw error;
|
|
300
|
+
}
|
|
227
301
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
(
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
return await this._runCommand(orderedCmd);
|
|
262
|
-
}
|
|
263
|
-
async updateUser(username, userDoc, writeConcern) {
|
|
264
|
-
(0, helpers_1.assertArgsDefinedType)([username, userDoc], ['string', 'object'], 'Database.updateUser');
|
|
265
|
-
this._emitDatabaseApiCall('updateUser', {});
|
|
266
|
-
if (userDoc.passwordDigestor &&
|
|
267
|
-
userDoc.passwordDigestor !== 'server' &&
|
|
268
|
-
userDoc.passwordDigestor !== 'client') {
|
|
269
|
-
throw new errors_1.MongoshInvalidInputError(`Invalid field: passwordDigestor must be 'client' or 'server', got ${userDoc.passwordDigestor}`, errors_1.CommonErrors.InvalidArgument);
|
|
270
|
-
}
|
|
271
|
-
const command = (0, helpers_1.adaptOptions)({ passwordDigestor: null }, {
|
|
272
|
-
updateUser: username,
|
|
273
|
-
}, userDoc);
|
|
274
|
-
if (writeConcern) {
|
|
275
|
-
command.writeConcern = writeConcern;
|
|
276
|
-
}
|
|
277
|
-
const digestPwd = (0, helpers_1.processDigestPassword)(username, userDoc.passwordDigestor, command);
|
|
278
|
-
const orderedCmd = {
|
|
279
|
-
updateUser: command.updateUser,
|
|
280
|
-
...command,
|
|
281
|
-
...digestPwd,
|
|
282
|
-
};
|
|
283
|
-
return await this._runCommand(orderedCmd);
|
|
284
|
-
}
|
|
285
|
-
async changeUserPassword(username, password, writeConcern) {
|
|
286
|
-
(0, helpers_1.assertArgsDefinedType)([username, password], ['string', 'string'], 'Database.changeUserPassword');
|
|
287
|
-
this._emitDatabaseApiCall('changeUserPassword', {});
|
|
288
|
-
const command = (0, helpers_1.adaptOptions)({}, {
|
|
289
|
-
updateUser: username,
|
|
290
|
-
pwd: password,
|
|
291
|
-
}, {});
|
|
292
|
-
if (writeConcern) {
|
|
293
|
-
command.writeConcern = writeConcern;
|
|
294
|
-
}
|
|
295
|
-
const orderedCmd = { updateUser: command.updateUser, ...command };
|
|
296
|
-
return await this._runCommand(orderedCmd);
|
|
297
|
-
}
|
|
298
|
-
async logout() {
|
|
299
|
-
this._emitDatabaseApiCall('logout', {});
|
|
300
|
-
this._mongo._instanceState.currentCursor = null;
|
|
301
|
-
return await this._runCommand({ logout: 1 });
|
|
302
|
-
}
|
|
303
|
-
async dropUser(username, writeConcern) {
|
|
304
|
-
(0, helpers_1.assertArgsDefinedType)([username], ['string'], 'Database.dropUser');
|
|
305
|
-
this._emitDatabaseApiCall('dropUser', {});
|
|
306
|
-
const cmd = { dropUser: username };
|
|
307
|
-
if (writeConcern) {
|
|
308
|
-
cmd.writeConcern = writeConcern;
|
|
309
|
-
}
|
|
310
|
-
return await this._runCommand(cmd);
|
|
311
|
-
}
|
|
312
|
-
async dropAllUsers(writeConcern) {
|
|
313
|
-
this._emitDatabaseApiCall('dropAllUsers', {});
|
|
314
|
-
const cmd = { dropAllUsersFromDatabase: 1 };
|
|
315
|
-
if (writeConcern) {
|
|
316
|
-
cmd.writeConcern = writeConcern;
|
|
302
|
+
async adminCommand(cmd) {
|
|
303
|
+
(0, helpers_1.assertArgsDefinedType)([cmd], [['string', 'object']], 'Database.adminCommand');
|
|
304
|
+
if (typeof cmd === 'string') {
|
|
305
|
+
cmd = { [cmd]: 1 };
|
|
306
|
+
}
|
|
307
|
+
const hiddenCommands = new RegExp(history_1.HIDDEN_COMMANDS);
|
|
308
|
+
if (!Object.keys(cmd).some((k) => hiddenCommands.test(k))) {
|
|
309
|
+
this._emitDatabaseApiCall('adminCommand', { cmd });
|
|
310
|
+
}
|
|
311
|
+
return await this._runAdminCommand(cmd, {});
|
|
312
|
+
}
|
|
313
|
+
async aggregate(pipeline, options) {
|
|
314
|
+
(0, helpers_1.assertArgsDefinedType)([pipeline], [true], 'Database.aggregate');
|
|
315
|
+
this._emitDatabaseApiCall('aggregate', { options, pipeline });
|
|
316
|
+
const { aggOptions, dbOptions, explain } = (0, helpers_1.adaptAggregateOptions)(options);
|
|
317
|
+
const providerCursor = this._mongo._serviceProvider.aggregateDb(this._name, pipeline, { ...(await this._baseOptions()), ...aggOptions }, dbOptions);
|
|
318
|
+
const cursor = new index_1.AggregationCursor(this._mongo, providerCursor);
|
|
319
|
+
if (explain) {
|
|
320
|
+
return await cursor.explain(explain);
|
|
321
|
+
}
|
|
322
|
+
else if ((0, helpers_1.shouldRunAggregationImmediately)(pipeline)) {
|
|
323
|
+
await cursor.hasNext();
|
|
324
|
+
}
|
|
325
|
+
this._mongo._instanceState.currentCursor = cursor;
|
|
326
|
+
return cursor;
|
|
327
|
+
}
|
|
328
|
+
getSiblingDB(db) {
|
|
329
|
+
(0, helpers_1.assertArgsDefinedType)([db], ['string'], 'Database.getSiblingDB');
|
|
330
|
+
this._emitDatabaseApiCall('getSiblingDB', { db });
|
|
331
|
+
if (this._session) {
|
|
332
|
+
return this._session.getDatabase(db);
|
|
333
|
+
}
|
|
334
|
+
return this._mongo._getDb(db);
|
|
317
335
|
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
const
|
|
325
|
-
if (
|
|
336
|
+
getCollection(coll) {
|
|
337
|
+
(0, helpers_1.assertArgsDefinedType)([coll], ['string'], 'Database.getColl');
|
|
338
|
+
this._emitDatabaseApiCall('getCollection', { coll });
|
|
339
|
+
if (!(0, helpers_1.isValidCollectionName)(coll)) {
|
|
340
|
+
throw new errors_1.MongoshInvalidInputError(`Invalid collection name: ${coll}`, errors_1.CommonErrors.InvalidArgument);
|
|
341
|
+
}
|
|
342
|
+
const collections = this._collections;
|
|
343
|
+
if (!collections[coll]) {
|
|
344
|
+
collections[coll] = new collection_1.default(this._mongo, this, coll);
|
|
345
|
+
}
|
|
346
|
+
return collections[coll];
|
|
347
|
+
}
|
|
348
|
+
async dropDatabase(writeConcern) {
|
|
349
|
+
return await this._mongo._serviceProvider.dropDatabase(this._name, {
|
|
350
|
+
...(await this._baseOptions()),
|
|
351
|
+
writeConcern,
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
async createUser(user, writeConcern) {
|
|
355
|
+
(0, helpers_1.assertArgsDefinedType)([user], ['object'], 'Database.createUser');
|
|
356
|
+
(0, helpers_1.assertKeysDefined)(user, ['user', 'roles']);
|
|
357
|
+
if (this._name === '$external') {
|
|
358
|
+
if ('pwd' in user) {
|
|
359
|
+
throw new errors_1.MongoshInvalidInputError('Cannot set password for users on the $external database', errors_1.CommonErrors.InvalidArgument);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
else {
|
|
363
|
+
(0, helpers_1.assertKeysDefined)(user, ['pwd']);
|
|
364
|
+
}
|
|
365
|
+
this._emitDatabaseApiCall('createUser', {});
|
|
366
|
+
if (user.createUser) {
|
|
367
|
+
throw new errors_1.MongoshInvalidInputError('Cannot set createUser field in helper method', errors_1.CommonErrors.InvalidArgument);
|
|
368
|
+
}
|
|
369
|
+
const command = (0, helpers_1.adaptOptions)({ user: 'createUser', passwordDigestor: null }, {}, user);
|
|
370
|
+
if (writeConcern) {
|
|
371
|
+
command.writeConcern = writeConcern;
|
|
372
|
+
}
|
|
373
|
+
const digestPwd = (0, helpers_1.processDigestPassword)(user.user, user.passwordDigestor, command);
|
|
374
|
+
const orderedCmd = {
|
|
375
|
+
createUser: command.createUser,
|
|
376
|
+
...command,
|
|
377
|
+
...digestPwd,
|
|
378
|
+
};
|
|
379
|
+
return await this._runCommand(orderedCmd);
|
|
380
|
+
}
|
|
381
|
+
async updateUser(username, userDoc, writeConcern) {
|
|
382
|
+
(0, helpers_1.assertArgsDefinedType)([username, userDoc], ['string', 'object'], 'Database.updateUser');
|
|
383
|
+
this._emitDatabaseApiCall('updateUser', {});
|
|
384
|
+
if (userDoc.passwordDigestor &&
|
|
385
|
+
userDoc.passwordDigestor !== 'server' &&
|
|
386
|
+
userDoc.passwordDigestor !== 'client') {
|
|
387
|
+
throw new errors_1.MongoshInvalidInputError(`Invalid field: passwordDigestor must be 'client' or 'server', got ${userDoc.passwordDigestor}`, errors_1.CommonErrors.InvalidArgument);
|
|
388
|
+
}
|
|
389
|
+
const command = (0, helpers_1.adaptOptions)({ passwordDigestor: null }, {
|
|
390
|
+
updateUser: username,
|
|
391
|
+
}, userDoc);
|
|
392
|
+
if (writeConcern) {
|
|
393
|
+
command.writeConcern = writeConcern;
|
|
394
|
+
}
|
|
395
|
+
const digestPwd = (0, helpers_1.processDigestPassword)(username, userDoc.passwordDigestor, command);
|
|
396
|
+
const orderedCmd = {
|
|
397
|
+
updateUser: command.updateUser,
|
|
398
|
+
...command,
|
|
399
|
+
...digestPwd,
|
|
400
|
+
};
|
|
401
|
+
return await this._runCommand(orderedCmd);
|
|
402
|
+
}
|
|
403
|
+
async changeUserPassword(username, password, writeConcern) {
|
|
404
|
+
(0, helpers_1.assertArgsDefinedType)([username, password], ['string', 'string'], 'Database.changeUserPassword');
|
|
405
|
+
this._emitDatabaseApiCall('changeUserPassword', {});
|
|
406
|
+
const command = (0, helpers_1.adaptOptions)({}, {
|
|
407
|
+
updateUser: username,
|
|
408
|
+
pwd: password,
|
|
409
|
+
}, {});
|
|
410
|
+
if (writeConcern) {
|
|
411
|
+
command.writeConcern = writeConcern;
|
|
412
|
+
}
|
|
413
|
+
const orderedCmd = { updateUser: command.updateUser, ...command };
|
|
414
|
+
return await this._runCommand(orderedCmd);
|
|
415
|
+
}
|
|
416
|
+
async logout() {
|
|
417
|
+
this._emitDatabaseApiCall('logout', {});
|
|
418
|
+
this._mongo._instanceState.currentCursor = null;
|
|
419
|
+
return await this._runCommand({ logout: 1 });
|
|
420
|
+
}
|
|
421
|
+
async dropUser(username, writeConcern) {
|
|
422
|
+
(0, helpers_1.assertArgsDefinedType)([username], ['string'], 'Database.dropUser');
|
|
423
|
+
this._emitDatabaseApiCall('dropUser', {});
|
|
424
|
+
const cmd = { dropUser: username };
|
|
425
|
+
if (writeConcern) {
|
|
426
|
+
cmd.writeConcern = writeConcern;
|
|
427
|
+
}
|
|
428
|
+
return await this._runCommand(cmd);
|
|
429
|
+
}
|
|
430
|
+
async dropAllUsers(writeConcern) {
|
|
431
|
+
this._emitDatabaseApiCall('dropAllUsers', {});
|
|
432
|
+
const cmd = { dropAllUsersFromDatabase: 1 };
|
|
433
|
+
if (writeConcern) {
|
|
434
|
+
cmd.writeConcern = writeConcern;
|
|
435
|
+
}
|
|
436
|
+
return await this._runCommand(cmd);
|
|
437
|
+
}
|
|
438
|
+
async auth(...args) {
|
|
439
|
+
this._emitDatabaseApiCall('auth', {});
|
|
440
|
+
let authDoc;
|
|
441
|
+
if (args.length === 1) {
|
|
442
|
+
const { evaluationListener } = this._mongo._instanceState;
|
|
443
|
+
if (typeof args[0] === 'string' && evaluationListener.onPrompt) {
|
|
444
|
+
authDoc = {
|
|
445
|
+
user: args[0],
|
|
446
|
+
pwd: await evaluationListener.onPrompt('Enter password', 'password'),
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
else {
|
|
450
|
+
authDoc = args[0];
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
else if (args.length === 2) {
|
|
326
454
|
authDoc = {
|
|
327
455
|
user: args[0],
|
|
328
|
-
pwd:
|
|
456
|
+
pwd: args[1],
|
|
329
457
|
};
|
|
330
458
|
}
|
|
331
459
|
else {
|
|
332
|
-
|
|
460
|
+
throw new errors_1.MongoshInvalidInputError('auth expects (username), (username, password), or ({ user: username, pwd: password })', errors_1.CommonErrors.InvalidArgument);
|
|
461
|
+
}
|
|
462
|
+
if ((!authDoc.user || !authDoc.pwd) && !authDoc.mechanism) {
|
|
463
|
+
throw new errors_1.MongoshInvalidInputError("auth expects user document with at least 'user' and 'pwd' or 'mechanism' fields", errors_1.CommonErrors.InvalidArgument);
|
|
464
|
+
}
|
|
465
|
+
if ('digestPassword' in authDoc) {
|
|
466
|
+
throw new errors_1.MongoshUnimplementedError('digestPassword is not supported for authentication.', errors_1.CommonErrors.NotImplemented);
|
|
333
467
|
}
|
|
468
|
+
authDoc.authDb = this._name;
|
|
469
|
+
this._mongo._instanceState.currentCursor = null;
|
|
470
|
+
return await this._mongo._serviceProvider.authenticate(authDoc);
|
|
471
|
+
}
|
|
472
|
+
async grantRolesToUser(username, roles, writeConcern) {
|
|
473
|
+
(0, helpers_1.assertArgsDefinedType)([username, roles], ['string', true], 'Database.grantRolesToUser');
|
|
474
|
+
this._emitDatabaseApiCall('grantRolesToUser', {});
|
|
475
|
+
const cmd = { grantRolesToUser: username, roles: roles };
|
|
476
|
+
if (writeConcern) {
|
|
477
|
+
cmd.writeConcern = writeConcern;
|
|
478
|
+
}
|
|
479
|
+
return await this._runCommand(cmd);
|
|
480
|
+
}
|
|
481
|
+
async revokeRolesFromUser(username, roles, writeConcern) {
|
|
482
|
+
(0, helpers_1.assertArgsDefinedType)([username, roles], ['string', true], 'Database.revokeRolesFromUser');
|
|
483
|
+
this._emitDatabaseApiCall('revokeRolesFromUser', {});
|
|
484
|
+
const cmd = { revokeRolesFromUser: username, roles: roles };
|
|
485
|
+
if (writeConcern) {
|
|
486
|
+
cmd.writeConcern = writeConcern;
|
|
487
|
+
}
|
|
488
|
+
return await this._runCommand(cmd);
|
|
489
|
+
}
|
|
490
|
+
async getUser(username, options = {}) {
|
|
491
|
+
(0, helpers_1.assertArgsDefinedType)([username], ['string'], 'Database.getUser');
|
|
492
|
+
this._emitDatabaseApiCall('getUser', { username: username });
|
|
493
|
+
const command = (0, helpers_1.adaptOptions)({}, { usersInfo: { user: username, db: this._name } }, options);
|
|
494
|
+
const result = await this._runReadCommand(command);
|
|
495
|
+
if (result.users === undefined) {
|
|
496
|
+
throw new errors_1.MongoshInternalError('No users were returned from the userInfo command');
|
|
497
|
+
}
|
|
498
|
+
for (let i = 0; i < result.users.length; i++) {
|
|
499
|
+
if (result.users[i].user === username) {
|
|
500
|
+
return result.users[i];
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
return null;
|
|
504
|
+
}
|
|
505
|
+
async getUsers(options = {}) {
|
|
506
|
+
this._emitDatabaseApiCall('getUsers', { options: options });
|
|
507
|
+
const command = (0, helpers_1.adaptOptions)({}, { usersInfo: 1 }, options);
|
|
508
|
+
return await this._runReadCommand(command);
|
|
509
|
+
}
|
|
510
|
+
async createCollection(name, options = {}) {
|
|
511
|
+
(0, helpers_1.assertArgsDefinedType)([name], ['string'], 'Database.createCollection');
|
|
512
|
+
this._emitDatabaseApiCall('createCollection', {
|
|
513
|
+
name: name,
|
|
514
|
+
options: options,
|
|
515
|
+
});
|
|
516
|
+
return await this._mongo._serviceProvider.createCollection(this._name, name, { ...(await this._baseOptions()), ...options });
|
|
334
517
|
}
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
518
|
+
async createEncryptedCollection(name, options) {
|
|
519
|
+
this._emitDatabaseApiCall('createEncryptedCollection', {
|
|
520
|
+
name: name,
|
|
521
|
+
options: options,
|
|
522
|
+
});
|
|
523
|
+
return this._mongo
|
|
524
|
+
.getClientEncryption()
|
|
525
|
+
.createEncryptedCollection(this._name, name, options);
|
|
526
|
+
}
|
|
527
|
+
async createView(name, source, pipeline, options = {}) {
|
|
528
|
+
(0, helpers_1.assertArgsDefinedType)([name, source, pipeline], ['string', 'string', true], 'Database.createView');
|
|
529
|
+
this._emitDatabaseApiCall('createView', {
|
|
530
|
+
name,
|
|
531
|
+
source,
|
|
532
|
+
pipeline,
|
|
533
|
+
options,
|
|
534
|
+
});
|
|
535
|
+
const ccOpts = {
|
|
536
|
+
...(await this._baseOptions()),
|
|
537
|
+
viewOn: source,
|
|
538
|
+
pipeline: pipeline,
|
|
339
539
|
};
|
|
540
|
+
if (options.collation) {
|
|
541
|
+
ccOpts.collation = options.collation;
|
|
542
|
+
}
|
|
543
|
+
return await this._mongo._serviceProvider.createCollection(this._name, name, ccOpts);
|
|
544
|
+
}
|
|
545
|
+
async createRole(role, writeConcern) {
|
|
546
|
+
(0, helpers_1.assertArgsDefinedType)([role], ['object'], 'Database.createRole');
|
|
547
|
+
(0, helpers_1.assertKeysDefined)(role, ['role', 'privileges', 'roles']);
|
|
548
|
+
this._emitDatabaseApiCall('createRole', {});
|
|
549
|
+
if (role.createRole) {
|
|
550
|
+
throw new errors_1.MongoshInvalidInputError('Cannot set createRole field in helper method', errors_1.CommonErrors.InvalidArgument);
|
|
551
|
+
}
|
|
552
|
+
const command = (0, helpers_1.adaptOptions)({ role: 'createRole' }, {}, role);
|
|
553
|
+
if (writeConcern) {
|
|
554
|
+
command.writeConcern = writeConcern;
|
|
555
|
+
}
|
|
556
|
+
const orderedCmd = { createRole: command.createRole, ...command };
|
|
557
|
+
return await this._runCommand(orderedCmd);
|
|
558
|
+
}
|
|
559
|
+
async updateRole(rolename, roleDoc, writeConcern) {
|
|
560
|
+
(0, helpers_1.assertArgsDefinedType)([rolename, roleDoc], ['string', 'object'], 'Database.updateRole');
|
|
561
|
+
this._emitDatabaseApiCall('updateRole', {});
|
|
562
|
+
const command = (0, helpers_1.adaptOptions)({}, {
|
|
563
|
+
updateRole: rolename,
|
|
564
|
+
}, roleDoc);
|
|
565
|
+
if (writeConcern) {
|
|
566
|
+
command.writeConcern = writeConcern;
|
|
567
|
+
}
|
|
568
|
+
const orderedCmd = { updateRole: command.updateRole, ...command };
|
|
569
|
+
return await this._runCommand(orderedCmd);
|
|
570
|
+
}
|
|
571
|
+
async dropRole(rolename, writeConcern) {
|
|
572
|
+
(0, helpers_1.assertArgsDefinedType)([rolename], ['string'], 'Database.dropRole');
|
|
573
|
+
this._emitDatabaseApiCall('dropRole', {});
|
|
574
|
+
const cmd = { dropRole: rolename };
|
|
575
|
+
if (writeConcern) {
|
|
576
|
+
cmd.writeConcern = writeConcern;
|
|
577
|
+
}
|
|
578
|
+
return await this._runCommand(cmd);
|
|
340
579
|
}
|
|
341
|
-
|
|
342
|
-
|
|
580
|
+
async dropAllRoles(writeConcern) {
|
|
581
|
+
this._emitDatabaseApiCall('dropAllRoles', {});
|
|
582
|
+
const cmd = { dropAllRolesFromDatabase: 1 };
|
|
583
|
+
if (writeConcern) {
|
|
584
|
+
cmd.writeConcern = writeConcern;
|
|
585
|
+
}
|
|
586
|
+
return await this._runCommand(cmd);
|
|
587
|
+
}
|
|
588
|
+
async grantRolesToRole(rolename, roles, writeConcern) {
|
|
589
|
+
(0, helpers_1.assertArgsDefinedType)([rolename, roles], ['string', true], 'Database.grantRolesToRole');
|
|
590
|
+
this._emitDatabaseApiCall('grantRolesToRole', {});
|
|
591
|
+
const cmd = { grantRolesToRole: rolename, roles: roles };
|
|
592
|
+
if (writeConcern) {
|
|
593
|
+
cmd.writeConcern = writeConcern;
|
|
594
|
+
}
|
|
595
|
+
return await this._runCommand(cmd);
|
|
596
|
+
}
|
|
597
|
+
async revokeRolesFromRole(rolename, roles, writeConcern) {
|
|
598
|
+
(0, helpers_1.assertArgsDefinedType)([rolename, roles], ['string', true], 'Database.revokeRolesFromRole');
|
|
599
|
+
this._emitDatabaseApiCall('revokeRolesFromRole', {});
|
|
600
|
+
const cmd = { revokeRolesFromRole: rolename, roles: roles };
|
|
601
|
+
if (writeConcern) {
|
|
602
|
+
cmd.writeConcern = writeConcern;
|
|
603
|
+
}
|
|
604
|
+
return await this._runCommand(cmd);
|
|
605
|
+
}
|
|
606
|
+
async grantPrivilegesToRole(rolename, privileges, writeConcern) {
|
|
607
|
+
(0, helpers_1.assertArgsDefinedType)([rolename, privileges], ['string', true], 'Database.grantPrivilegesToRole');
|
|
608
|
+
this._emitDatabaseApiCall('grantPrivilegesToRole', {});
|
|
609
|
+
const cmd = {
|
|
610
|
+
grantPrivilegesToRole: rolename,
|
|
611
|
+
privileges: privileges,
|
|
612
|
+
};
|
|
613
|
+
if (writeConcern) {
|
|
614
|
+
cmd.writeConcern = writeConcern;
|
|
615
|
+
}
|
|
616
|
+
return await this._runCommand(cmd);
|
|
617
|
+
}
|
|
618
|
+
async revokePrivilegesFromRole(rolename, privileges, writeConcern) {
|
|
619
|
+
(0, helpers_1.assertArgsDefinedType)([rolename, privileges], ['string', true], 'Database.revokePrivilegesFromRole');
|
|
620
|
+
this._emitDatabaseApiCall('revokePrivilegesFromRole', {});
|
|
621
|
+
const cmd = {
|
|
622
|
+
revokePrivilegesFromRole: rolename,
|
|
623
|
+
privileges: privileges,
|
|
624
|
+
};
|
|
625
|
+
if (writeConcern) {
|
|
626
|
+
cmd.writeConcern = writeConcern;
|
|
627
|
+
}
|
|
628
|
+
return await this._runCommand(cmd);
|
|
629
|
+
}
|
|
630
|
+
async getRole(rolename, options = {}) {
|
|
631
|
+
(0, helpers_1.assertArgsDefinedType)([rolename], ['string'], 'Database.getRole');
|
|
632
|
+
this._emitDatabaseApiCall('getRole', { rolename: rolename });
|
|
633
|
+
const command = (0, helpers_1.adaptOptions)({}, { rolesInfo: { role: rolename, db: this._name } }, options);
|
|
634
|
+
const result = await this._runReadCommand(command);
|
|
635
|
+
if (result.roles === undefined) {
|
|
636
|
+
throw new errors_1.MongoshInternalError('No roles returned from rolesInfo command');
|
|
637
|
+
}
|
|
638
|
+
for (let i = 0; i < result.roles.length; i++) {
|
|
639
|
+
if (result.roles[i].role === rolename) {
|
|
640
|
+
return result.roles[i];
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
return null;
|
|
644
|
+
}
|
|
645
|
+
async getRoles(options = {}) {
|
|
646
|
+
this._emitDatabaseApiCall('getRoles', { options: options });
|
|
647
|
+
const command = (0, helpers_1.adaptOptions)({}, { rolesInfo: 1 }, options);
|
|
648
|
+
return await this._runReadCommand(command);
|
|
649
|
+
}
|
|
650
|
+
async _getCurrentOperations(opts) {
|
|
651
|
+
const legacyCurrentOpOptions = typeof opts === 'boolean'
|
|
652
|
+
? { $all: opts, $ownOps: false }
|
|
653
|
+
: { $all: !!opts.$all, $ownOps: !!opts.$ownOps };
|
|
654
|
+
const pipeline = [
|
|
655
|
+
{
|
|
656
|
+
$currentOp: {
|
|
657
|
+
allUsers: !legacyCurrentOpOptions.$ownOps,
|
|
658
|
+
idleConnections: legacyCurrentOpOptions.$all,
|
|
659
|
+
truncateOps: false,
|
|
660
|
+
},
|
|
661
|
+
},
|
|
662
|
+
];
|
|
663
|
+
if (typeof opts === 'object') {
|
|
664
|
+
const matchingFilters = {};
|
|
665
|
+
for (const filtername of Object.keys(opts)) {
|
|
666
|
+
if (filtername !== '$ownOps' &&
|
|
667
|
+
filtername !== '$all' &&
|
|
668
|
+
filtername !== '$truncateOps') {
|
|
669
|
+
matchingFilters[filtername] = opts[filtername];
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
pipeline.push({ $match: matchingFilters });
|
|
673
|
+
}
|
|
674
|
+
const adminDb = this.getSiblingDB('admin');
|
|
675
|
+
const aggregateOptions = { $readPreference: { mode: 'primaryPreferred' } };
|
|
676
|
+
try {
|
|
677
|
+
const cursor = await adminDb.aggregate(pipeline, aggregateOptions);
|
|
678
|
+
return await cursor.toArray();
|
|
679
|
+
}
|
|
680
|
+
catch (error) {
|
|
681
|
+
if ((error === null || error === void 0 ? void 0 : error.codeName) === 'FailedToParse') {
|
|
682
|
+
delete pipeline[0].$currentOp.truncateOps;
|
|
683
|
+
const cursor = await adminDb.aggregate(pipeline, aggregateOptions);
|
|
684
|
+
return await cursor.toArray();
|
|
685
|
+
}
|
|
686
|
+
throw error;
|
|
687
|
+
}
|
|
343
688
|
}
|
|
344
|
-
|
|
345
|
-
|
|
689
|
+
async currentOp(opts = {}) {
|
|
690
|
+
this._emitDatabaseApiCall('currentOp', { opts: opts });
|
|
691
|
+
const currentOps = await this._getCurrentOperations(opts);
|
|
692
|
+
return {
|
|
693
|
+
inprog: currentOps,
|
|
694
|
+
ok: 1,
|
|
695
|
+
};
|
|
346
696
|
}
|
|
347
|
-
|
|
348
|
-
|
|
697
|
+
async killOp(opId) {
|
|
698
|
+
this._emitDatabaseApiCall('killOp', { opId });
|
|
699
|
+
return await this._runAdminCommand({
|
|
700
|
+
killOp: 1,
|
|
701
|
+
op: opId,
|
|
702
|
+
});
|
|
349
703
|
}
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
this._emitDatabaseApiCall('grantRolesToUser', {});
|
|
357
|
-
const cmd = { grantRolesToUser: username, roles: roles };
|
|
358
|
-
if (writeConcern) {
|
|
359
|
-
cmd.writeConcern = writeConcern;
|
|
360
|
-
}
|
|
361
|
-
return await this._runCommand(cmd);
|
|
362
|
-
}
|
|
363
|
-
async revokeRolesFromUser(username, roles, writeConcern) {
|
|
364
|
-
(0, helpers_1.assertArgsDefinedType)([username, roles], ['string', true], 'Database.revokeRolesFromUser');
|
|
365
|
-
this._emitDatabaseApiCall('revokeRolesFromUser', {});
|
|
366
|
-
const cmd = { revokeRolesFromUser: username, roles: roles };
|
|
367
|
-
if (writeConcern) {
|
|
368
|
-
cmd.writeConcern = writeConcern;
|
|
369
|
-
}
|
|
370
|
-
return await this._runCommand(cmd);
|
|
371
|
-
}
|
|
372
|
-
async getUser(username, options = {}) {
|
|
373
|
-
(0, helpers_1.assertArgsDefinedType)([username], ['string'], 'Database.getUser');
|
|
374
|
-
this._emitDatabaseApiCall('getUser', { username: username });
|
|
375
|
-
const command = (0, helpers_1.adaptOptions)({}, { usersInfo: { user: username, db: this._name } }, options);
|
|
376
|
-
const result = await this._runReadCommand(command);
|
|
377
|
-
if (result.users === undefined) {
|
|
378
|
-
throw new errors_1.MongoshInternalError('No users were returned from the userInfo command');
|
|
704
|
+
async shutdownServer(opts = {}) {
|
|
705
|
+
this._emitDatabaseApiCall('shutdownServer', { opts: opts });
|
|
706
|
+
return await this._runAdminCommand({
|
|
707
|
+
shutdown: 1,
|
|
708
|
+
...opts,
|
|
709
|
+
});
|
|
379
710
|
}
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
711
|
+
async fsyncLock() {
|
|
712
|
+
this._emitDatabaseApiCall('fsyncLock', {});
|
|
713
|
+
return await this._runAdminCommand({
|
|
714
|
+
fsync: 1,
|
|
715
|
+
lock: true,
|
|
716
|
+
});
|
|
384
717
|
}
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
return await this._runReadCommand(command);
|
|
391
|
-
}
|
|
392
|
-
async createCollection(name, options = {}) {
|
|
393
|
-
(0, helpers_1.assertArgsDefinedType)([name], ['string'], 'Database.createCollection');
|
|
394
|
-
this._emitDatabaseApiCall('createCollection', {
|
|
395
|
-
name: name,
|
|
396
|
-
options: options,
|
|
397
|
-
});
|
|
398
|
-
return await this._mongo._serviceProvider.createCollection(this._name, name, { ...(await this._baseOptions()), ...options });
|
|
399
|
-
}
|
|
400
|
-
async createEncryptedCollection(name, options) {
|
|
401
|
-
this._emitDatabaseApiCall('createEncryptedCollection', {
|
|
402
|
-
name: name,
|
|
403
|
-
options: options,
|
|
404
|
-
});
|
|
405
|
-
return this._mongo
|
|
406
|
-
.getClientEncryption()
|
|
407
|
-
.createEncryptedCollection(this._name, name, options);
|
|
408
|
-
}
|
|
409
|
-
async createView(name, source, pipeline, options = {}) {
|
|
410
|
-
(0, helpers_1.assertArgsDefinedType)([name, source, pipeline], ['string', 'string', true], 'Database.createView');
|
|
411
|
-
this._emitDatabaseApiCall('createView', {
|
|
412
|
-
name,
|
|
413
|
-
source,
|
|
414
|
-
pipeline,
|
|
415
|
-
options,
|
|
416
|
-
});
|
|
417
|
-
const ccOpts = {
|
|
418
|
-
...(await this._baseOptions()),
|
|
419
|
-
viewOn: source,
|
|
420
|
-
pipeline: pipeline,
|
|
421
|
-
};
|
|
422
|
-
if (options.collation) {
|
|
423
|
-
ccOpts.collation = options.collation;
|
|
424
|
-
}
|
|
425
|
-
return await this._mongo._serviceProvider.createCollection(this._name, name, ccOpts);
|
|
426
|
-
}
|
|
427
|
-
async createRole(role, writeConcern) {
|
|
428
|
-
(0, helpers_1.assertArgsDefinedType)([role], ['object'], 'Database.createRole');
|
|
429
|
-
(0, helpers_1.assertKeysDefined)(role, ['role', 'privileges', 'roles']);
|
|
430
|
-
this._emitDatabaseApiCall('createRole', {});
|
|
431
|
-
if (role.createRole) {
|
|
432
|
-
throw new errors_1.MongoshInvalidInputError('Cannot set createRole field in helper method', errors_1.CommonErrors.InvalidArgument);
|
|
433
|
-
}
|
|
434
|
-
const command = (0, helpers_1.adaptOptions)({ role: 'createRole' }, {}, role);
|
|
435
|
-
if (writeConcern) {
|
|
436
|
-
command.writeConcern = writeConcern;
|
|
437
|
-
}
|
|
438
|
-
const orderedCmd = { createRole: command.createRole, ...command };
|
|
439
|
-
return await this._runCommand(orderedCmd);
|
|
440
|
-
}
|
|
441
|
-
async updateRole(rolename, roleDoc, writeConcern) {
|
|
442
|
-
(0, helpers_1.assertArgsDefinedType)([rolename, roleDoc], ['string', 'object'], 'Database.updateRole');
|
|
443
|
-
this._emitDatabaseApiCall('updateRole', {});
|
|
444
|
-
const command = (0, helpers_1.adaptOptions)({}, {
|
|
445
|
-
updateRole: rolename,
|
|
446
|
-
}, roleDoc);
|
|
447
|
-
if (writeConcern) {
|
|
448
|
-
command.writeConcern = writeConcern;
|
|
449
|
-
}
|
|
450
|
-
const orderedCmd = { updateRole: command.updateRole, ...command };
|
|
451
|
-
return await this._runCommand(orderedCmd);
|
|
452
|
-
}
|
|
453
|
-
async dropRole(rolename, writeConcern) {
|
|
454
|
-
(0, helpers_1.assertArgsDefinedType)([rolename], ['string'], 'Database.dropRole');
|
|
455
|
-
this._emitDatabaseApiCall('dropRole', {});
|
|
456
|
-
const cmd = { dropRole: rolename };
|
|
457
|
-
if (writeConcern) {
|
|
458
|
-
cmd.writeConcern = writeConcern;
|
|
459
|
-
}
|
|
460
|
-
return await this._runCommand(cmd);
|
|
461
|
-
}
|
|
462
|
-
async dropAllRoles(writeConcern) {
|
|
463
|
-
this._emitDatabaseApiCall('dropAllRoles', {});
|
|
464
|
-
const cmd = { dropAllRolesFromDatabase: 1 };
|
|
465
|
-
if (writeConcern) {
|
|
466
|
-
cmd.writeConcern = writeConcern;
|
|
718
|
+
async fsyncUnlock() {
|
|
719
|
+
this._emitDatabaseApiCall('fsyncUnlock', {});
|
|
720
|
+
return await this._runAdminCommand({
|
|
721
|
+
fsyncUnlock: 1,
|
|
722
|
+
});
|
|
467
723
|
}
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
return await this._runCommand(cmd);
|
|
478
|
-
}
|
|
479
|
-
async revokeRolesFromRole(rolename, roles, writeConcern) {
|
|
480
|
-
(0, helpers_1.assertArgsDefinedType)([rolename, roles], ['string', true], 'Database.revokeRolesFromRole');
|
|
481
|
-
this._emitDatabaseApiCall('revokeRolesFromRole', {});
|
|
482
|
-
const cmd = { revokeRolesFromRole: rolename, roles: roles };
|
|
483
|
-
if (writeConcern) {
|
|
484
|
-
cmd.writeConcern = writeConcern;
|
|
485
|
-
}
|
|
486
|
-
return await this._runCommand(cmd);
|
|
487
|
-
}
|
|
488
|
-
async grantPrivilegesToRole(rolename, privileges, writeConcern) {
|
|
489
|
-
(0, helpers_1.assertArgsDefinedType)([rolename, privileges], ['string', true], 'Database.grantPrivilegesToRole');
|
|
490
|
-
this._emitDatabaseApiCall('grantPrivilegesToRole', {});
|
|
491
|
-
const cmd = {
|
|
492
|
-
grantPrivilegesToRole: rolename,
|
|
493
|
-
privileges: privileges,
|
|
494
|
-
};
|
|
495
|
-
if (writeConcern) {
|
|
496
|
-
cmd.writeConcern = writeConcern;
|
|
497
|
-
}
|
|
498
|
-
return await this._runCommand(cmd);
|
|
499
|
-
}
|
|
500
|
-
async revokePrivilegesFromRole(rolename, privileges, writeConcern) {
|
|
501
|
-
(0, helpers_1.assertArgsDefinedType)([rolename, privileges], ['string', true], 'Database.revokePrivilegesFromRole');
|
|
502
|
-
this._emitDatabaseApiCall('revokePrivilegesFromRole', {});
|
|
503
|
-
const cmd = {
|
|
504
|
-
revokePrivilegesFromRole: rolename,
|
|
505
|
-
privileges: privileges,
|
|
506
|
-
};
|
|
507
|
-
if (writeConcern) {
|
|
508
|
-
cmd.writeConcern = writeConcern;
|
|
509
|
-
}
|
|
510
|
-
return await this._runCommand(cmd);
|
|
511
|
-
}
|
|
512
|
-
async getRole(rolename, options = {}) {
|
|
513
|
-
(0, helpers_1.assertArgsDefinedType)([rolename], ['string'], 'Database.getRole');
|
|
514
|
-
this._emitDatabaseApiCall('getRole', { rolename: rolename });
|
|
515
|
-
const command = (0, helpers_1.adaptOptions)({}, { rolesInfo: { role: rolename, db: this._name } }, options);
|
|
516
|
-
const result = await this._runReadCommand(command);
|
|
517
|
-
if (result.roles === undefined) {
|
|
518
|
-
throw new errors_1.MongoshInternalError('No roles returned from rolesInfo command');
|
|
724
|
+
async version() {
|
|
725
|
+
this._emitDatabaseApiCall('version', {});
|
|
726
|
+
const info = await this._runAdminCommand({
|
|
727
|
+
buildInfo: 1,
|
|
728
|
+
});
|
|
729
|
+
if (!info || info.version === undefined) {
|
|
730
|
+
throw new errors_1.MongoshRuntimeError(`Error running command serverBuildInfo ${info ? info.errmsg || '' : ''}`, errors_1.CommonErrors.CommandFailed);
|
|
731
|
+
}
|
|
732
|
+
return info.version;
|
|
519
733
|
}
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
734
|
+
async serverBits() {
|
|
735
|
+
this._emitDatabaseApiCall('serverBits', {});
|
|
736
|
+
const info = await this._runAdminCommand({
|
|
737
|
+
buildInfo: 1,
|
|
738
|
+
});
|
|
739
|
+
if (!info || info.bits === undefined) {
|
|
740
|
+
throw new errors_1.MongoshRuntimeError(`Error running command serverBuildInfo ${info ? info.errmsg || '' : ''}`, errors_1.CommonErrors.CommandFailed);
|
|
523
741
|
}
|
|
742
|
+
return info.bits;
|
|
524
743
|
}
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
for (const filtername of Object.keys(opts)) {
|
|
548
|
-
if (filtername !== '$ownOps' &&
|
|
549
|
-
filtername !== '$all' &&
|
|
550
|
-
filtername !== '$truncateOps') {
|
|
551
|
-
matchingFilters[filtername] = opts[filtername];
|
|
744
|
+
async isMaster() {
|
|
745
|
+
this._emitDatabaseApiCall('isMaster', {});
|
|
746
|
+
const result = await this._runReadCommand({
|
|
747
|
+
isMaster: 1,
|
|
748
|
+
});
|
|
749
|
+
result.isWritablePrimary = result.ismaster;
|
|
750
|
+
return result;
|
|
751
|
+
}
|
|
752
|
+
async hello() {
|
|
753
|
+
this._emitDatabaseApiCall('hello', {});
|
|
754
|
+
try {
|
|
755
|
+
this._cachedHello = await this._runReadCommand({
|
|
756
|
+
hello: 1,
|
|
757
|
+
});
|
|
758
|
+
return this._cachedHello;
|
|
759
|
+
}
|
|
760
|
+
catch (err) {
|
|
761
|
+
if ((err === null || err === void 0 ? void 0 : err.codeName) === 'CommandNotFound') {
|
|
762
|
+
const result = await this.isMaster();
|
|
763
|
+
delete result.ismaster;
|
|
764
|
+
this._cachedHello = result;
|
|
765
|
+
return this._cachedHello;
|
|
552
766
|
}
|
|
767
|
+
throw err;
|
|
553
768
|
}
|
|
554
|
-
pipeline.push({ $match: matchingFilters });
|
|
555
769
|
}
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
770
|
+
async serverBuildInfo() {
|
|
771
|
+
this._emitDatabaseApiCall('serverBuildInfo', {});
|
|
772
|
+
return await this._runAdminCommand({
|
|
773
|
+
buildInfo: 1,
|
|
774
|
+
});
|
|
561
775
|
}
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
776
|
+
async serverStatus(opts = {}) {
|
|
777
|
+
this._emitDatabaseApiCall('serverStatus', { options: opts });
|
|
778
|
+
return await this._runAdminCommand({
|
|
779
|
+
serverStatus: 1,
|
|
780
|
+
...opts,
|
|
781
|
+
});
|
|
782
|
+
}
|
|
783
|
+
async stats(scaleOrOptions = 1) {
|
|
784
|
+
(0, helpers_1.assertArgsDefinedType)([scaleOrOptions], [['number', 'object']], 'Database.stats');
|
|
785
|
+
if (typeof scaleOrOptions === 'number') {
|
|
786
|
+
scaleOrOptions = { scale: scaleOrOptions };
|
|
567
787
|
}
|
|
568
|
-
|
|
788
|
+
this._emitDatabaseApiCall('stats', { scale: scaleOrOptions.scale });
|
|
789
|
+
return await this._runReadCommand({
|
|
790
|
+
dbStats: 1,
|
|
791
|
+
scale: 1,
|
|
792
|
+
...scaleOrOptions,
|
|
793
|
+
});
|
|
569
794
|
}
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
return {
|
|
575
|
-
inprog: currentOps,
|
|
576
|
-
ok: 1,
|
|
577
|
-
};
|
|
578
|
-
}
|
|
579
|
-
async killOp(opId) {
|
|
580
|
-
this._emitDatabaseApiCall('killOp', { opId });
|
|
581
|
-
return await this._runAdminCommand({
|
|
582
|
-
killOp: 1,
|
|
583
|
-
op: opId,
|
|
584
|
-
});
|
|
585
|
-
}
|
|
586
|
-
async shutdownServer(opts = {}) {
|
|
587
|
-
this._emitDatabaseApiCall('shutdownServer', { opts: opts });
|
|
588
|
-
return await this._runAdminCommand({
|
|
589
|
-
shutdown: 1,
|
|
590
|
-
...opts,
|
|
591
|
-
});
|
|
592
|
-
}
|
|
593
|
-
async fsyncLock() {
|
|
594
|
-
this._emitDatabaseApiCall('fsyncLock', {});
|
|
595
|
-
return await this._runAdminCommand({
|
|
596
|
-
fsync: 1,
|
|
597
|
-
lock: true,
|
|
598
|
-
});
|
|
599
|
-
}
|
|
600
|
-
async fsyncUnlock() {
|
|
601
|
-
this._emitDatabaseApiCall('fsyncUnlock', {});
|
|
602
|
-
return await this._runAdminCommand({
|
|
603
|
-
fsyncUnlock: 1,
|
|
604
|
-
});
|
|
605
|
-
}
|
|
606
|
-
async version() {
|
|
607
|
-
this._emitDatabaseApiCall('version', {});
|
|
608
|
-
const info = await this._runAdminCommand({
|
|
609
|
-
buildInfo: 1,
|
|
610
|
-
});
|
|
611
|
-
if (!info || info.version === undefined) {
|
|
612
|
-
throw new errors_1.MongoshRuntimeError(`Error running command serverBuildInfo ${info ? info.errmsg || '' : ''}`, errors_1.CommonErrors.CommandFailed);
|
|
613
|
-
}
|
|
614
|
-
return info.version;
|
|
615
|
-
}
|
|
616
|
-
async serverBits() {
|
|
617
|
-
this._emitDatabaseApiCall('serverBits', {});
|
|
618
|
-
const info = await this._runAdminCommand({
|
|
619
|
-
buildInfo: 1,
|
|
620
|
-
});
|
|
621
|
-
if (!info || info.bits === undefined) {
|
|
622
|
-
throw new errors_1.MongoshRuntimeError(`Error running command serverBuildInfo ${info ? info.errmsg || '' : ''}`, errors_1.CommonErrors.CommandFailed);
|
|
623
|
-
}
|
|
624
|
-
return info.bits;
|
|
625
|
-
}
|
|
626
|
-
async isMaster() {
|
|
627
|
-
this._emitDatabaseApiCall('isMaster', {});
|
|
628
|
-
const result = await this._runReadCommand({
|
|
629
|
-
isMaster: 1,
|
|
630
|
-
});
|
|
631
|
-
result.isWritablePrimary = result.ismaster;
|
|
632
|
-
return result;
|
|
633
|
-
}
|
|
634
|
-
async hello() {
|
|
635
|
-
this._emitDatabaseApiCall('hello', {});
|
|
636
|
-
try {
|
|
637
|
-
this._cachedHello = await this._runReadCommand({
|
|
638
|
-
hello: 1,
|
|
795
|
+
async hostInfo() {
|
|
796
|
+
this._emitDatabaseApiCall('hostInfo', {});
|
|
797
|
+
return await this._runAdminCommand({
|
|
798
|
+
hostInfo: 1,
|
|
639
799
|
});
|
|
640
|
-
return this._cachedHello;
|
|
641
800
|
}
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
return this._cachedHello;
|
|
648
|
-
}
|
|
649
|
-
throw err;
|
|
801
|
+
async serverCmdLineOpts() {
|
|
802
|
+
this._emitDatabaseApiCall('serverCmdLineOpts', {});
|
|
803
|
+
return await this._runAdminCommand({
|
|
804
|
+
getCmdLineOpts: 1,
|
|
805
|
+
});
|
|
650
806
|
}
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
serverStatus: 1,
|
|
662
|
-
...opts,
|
|
663
|
-
});
|
|
664
|
-
}
|
|
665
|
-
async stats(scaleOrOptions = 1) {
|
|
666
|
-
(0, helpers_1.assertArgsDefinedType)([scaleOrOptions], [['number', 'object']], 'Database.stats');
|
|
667
|
-
if (typeof scaleOrOptions === 'number') {
|
|
668
|
-
scaleOrOptions = { scale: scaleOrOptions };
|
|
669
|
-
}
|
|
670
|
-
this._emitDatabaseApiCall('stats', { scale: scaleOrOptions.scale });
|
|
671
|
-
return await this._runReadCommand({
|
|
672
|
-
dbStats: 1,
|
|
673
|
-
scale: 1,
|
|
674
|
-
...scaleOrOptions,
|
|
675
|
-
});
|
|
676
|
-
}
|
|
677
|
-
async hostInfo() {
|
|
678
|
-
this._emitDatabaseApiCall('hostInfo', {});
|
|
679
|
-
return await this._runAdminCommand({
|
|
680
|
-
hostInfo: 1,
|
|
681
|
-
});
|
|
682
|
-
}
|
|
683
|
-
async serverCmdLineOpts() {
|
|
684
|
-
this._emitDatabaseApiCall('serverCmdLineOpts', {});
|
|
685
|
-
return await this._runAdminCommand({
|
|
686
|
-
getCmdLineOpts: 1,
|
|
687
|
-
});
|
|
688
|
-
}
|
|
689
|
-
async rotateCertificates(message) {
|
|
690
|
-
this._emitDatabaseApiCall('rotateCertificates', { message });
|
|
691
|
-
return await this._runAdminCommand({
|
|
692
|
-
rotateCertificates: 1,
|
|
693
|
-
message,
|
|
694
|
-
});
|
|
695
|
-
}
|
|
696
|
-
async printCollectionStats(scale = 1) {
|
|
697
|
-
if (typeof scale !== 'number' || scale < 1) {
|
|
698
|
-
throw new errors_1.MongoshInvalidInputError(`scale has to be a number >=1, got ${scale}`, errors_1.CommonErrors.InvalidArgument);
|
|
699
|
-
}
|
|
700
|
-
this._emitDatabaseApiCall('printCollectionStats', { scale: scale });
|
|
701
|
-
const colls = await this.getCollectionNames();
|
|
702
|
-
const result = {};
|
|
703
|
-
for (const c of colls) {
|
|
704
|
-
try {
|
|
705
|
-
result[c] = await this.getCollection(c).stats({ scale });
|
|
807
|
+
async rotateCertificates(message) {
|
|
808
|
+
this._emitDatabaseApiCall('rotateCertificates', { message });
|
|
809
|
+
return await this._runAdminCommand({
|
|
810
|
+
rotateCertificates: 1,
|
|
811
|
+
message,
|
|
812
|
+
});
|
|
813
|
+
}
|
|
814
|
+
async printCollectionStats(scale = 1) {
|
|
815
|
+
if (typeof scale !== 'number' || scale < 1) {
|
|
816
|
+
throw new errors_1.MongoshInvalidInputError(`scale has to be a number >=1, got ${scale}`, errors_1.CommonErrors.InvalidArgument);
|
|
706
817
|
}
|
|
707
|
-
|
|
708
|
-
|
|
818
|
+
this._emitDatabaseApiCall('printCollectionStats', { scale: scale });
|
|
819
|
+
const colls = await this.getCollectionNames();
|
|
820
|
+
const result = {};
|
|
821
|
+
for (const c of colls) {
|
|
822
|
+
try {
|
|
823
|
+
result[c] = await this.getCollection(c).stats({ scale });
|
|
824
|
+
}
|
|
825
|
+
catch (error) {
|
|
826
|
+
result[c] = { ok: 0, errmsg: error === null || error === void 0 ? void 0 : error.message };
|
|
827
|
+
}
|
|
709
828
|
}
|
|
829
|
+
return new index_1.CommandResult('StatsResult', result);
|
|
710
830
|
}
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
profile: -1,
|
|
717
|
-
});
|
|
718
|
-
}
|
|
719
|
-
async setProfilingLevel(level, opts = {}) {
|
|
720
|
-
(0, helpers_1.assertArgsDefinedType)([level], ['number'], 'Database.setProfilingLevel');
|
|
721
|
-
if (level < 0 || level > 2) {
|
|
722
|
-
throw new errors_1.MongoshInvalidInputError(`Input level ${level} is out of range [0..2]`, errors_1.CommonErrors.InvalidArgument);
|
|
723
|
-
}
|
|
724
|
-
if (typeof opts === 'number') {
|
|
725
|
-
opts = { slowms: opts };
|
|
726
|
-
}
|
|
727
|
-
this._emitDatabaseApiCall('setProfilingLevel', { opts: opts });
|
|
728
|
-
return await this._runCommand({
|
|
729
|
-
profile: level,
|
|
730
|
-
...opts,
|
|
731
|
-
});
|
|
732
|
-
}
|
|
733
|
-
async setLogLevel(logLevel, component) {
|
|
734
|
-
(0, helpers_1.assertArgsDefinedType)([logLevel], ['number'], 'Database.setLogLevel');
|
|
735
|
-
this._emitDatabaseApiCall('setLogLevel', {
|
|
736
|
-
logLevel: logLevel,
|
|
737
|
-
component: component,
|
|
738
|
-
});
|
|
739
|
-
let componentNames = [];
|
|
740
|
-
if (typeof component === 'string') {
|
|
741
|
-
componentNames = component.split('.');
|
|
742
|
-
}
|
|
743
|
-
else if (component !== undefined) {
|
|
744
|
-
throw new errors_1.MongoshInvalidInputError(`setLogLevel component must be a string: got ${typeof component}`, errors_1.CommonErrors.InvalidArgument);
|
|
745
|
-
}
|
|
746
|
-
let vDoc = { verbosity: logLevel };
|
|
747
|
-
while (componentNames.length > 0) {
|
|
748
|
-
const key = componentNames.pop();
|
|
749
|
-
vDoc = { [key]: vDoc };
|
|
750
|
-
}
|
|
751
|
-
const cmdObj = { setParameter: 1, logComponentVerbosity: vDoc };
|
|
752
|
-
return await this._runAdminCommand(cmdObj);
|
|
753
|
-
}
|
|
754
|
-
async getLogComponents() {
|
|
755
|
-
this._emitDatabaseApiCall('getLogComponents', {});
|
|
756
|
-
const cmdObj = { getParameter: 1, logComponentVerbosity: 1 };
|
|
757
|
-
const result = await this._runAdminCommand(cmdObj);
|
|
758
|
-
if (!result || result.logComponentVerbosity === undefined) {
|
|
759
|
-
throw new errors_1.MongoshRuntimeError(`Error running command ${result ? result.errmsg || '' : ''}`, errors_1.CommonErrors.CommandFailed);
|
|
760
|
-
}
|
|
761
|
-
return result.logComponentVerbosity;
|
|
762
|
-
}
|
|
763
|
-
cloneDatabase() {
|
|
764
|
-
throw new errors_1.MongoshDeprecatedError('`cloneDatabase()` was removed because it was deprecated in MongoDB 4.0');
|
|
765
|
-
}
|
|
766
|
-
cloneCollection() {
|
|
767
|
-
throw new errors_1.MongoshDeprecatedError('`cloneCollection()` was removed because it was deprecated in MongoDB 4.0');
|
|
768
|
-
}
|
|
769
|
-
copyDatabase() {
|
|
770
|
-
throw new errors_1.MongoshDeprecatedError('`copyDatabase()` was removed because it was deprecated in MongoDB 4.0');
|
|
771
|
-
}
|
|
772
|
-
async commandHelp(name) {
|
|
773
|
-
(0, helpers_1.assertArgsDefinedType)([name], ['string'], 'Database.commandHelp');
|
|
774
|
-
this._emitDatabaseApiCall('commandHelp', { name: name });
|
|
775
|
-
const command = {};
|
|
776
|
-
command[name] = 1;
|
|
777
|
-
command.help = true;
|
|
778
|
-
const result = await this._runCommand(command);
|
|
779
|
-
if (!result || result.help === undefined) {
|
|
780
|
-
throw new errors_1.MongoshRuntimeError(`Error running command commandHelp ${result ? result.errmsg || '' : ''}`, errors_1.CommonErrors.CommandFailed);
|
|
781
|
-
}
|
|
782
|
-
return result.help;
|
|
783
|
-
}
|
|
784
|
-
async listCommands() {
|
|
785
|
-
this._emitDatabaseApiCall('listCommands', {});
|
|
786
|
-
const result = await this._runReadCommand({
|
|
787
|
-
listCommands: 1,
|
|
788
|
-
});
|
|
789
|
-
if (!result || result.commands === undefined) {
|
|
790
|
-
throw new errors_1.MongoshRuntimeError(`Error running command listCommands ${result ? result.errmsg || '' : ''}`, errors_1.CommonErrors.CommandFailed);
|
|
831
|
+
async getProfilingStatus() {
|
|
832
|
+
this._emitDatabaseApiCall('getProfilingStatus', {});
|
|
833
|
+
return await this._runReadCommand({
|
|
834
|
+
profile: -1,
|
|
835
|
+
});
|
|
791
836
|
}
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
837
|
+
async setProfilingLevel(level, opts = {}) {
|
|
838
|
+
(0, helpers_1.assertArgsDefinedType)([level], ['number'], 'Database.setProfilingLevel');
|
|
839
|
+
if (level < 0 || level > 2) {
|
|
840
|
+
throw new errors_1.MongoshInvalidInputError(`Input level ${level} is out of range [0..2]`, errors_1.CommonErrors.InvalidArgument);
|
|
796
841
|
}
|
|
797
|
-
if ('
|
|
798
|
-
|
|
799
|
-
delete cmdDescription.slaveOverrideOk;
|
|
842
|
+
if (typeof opts === 'number') {
|
|
843
|
+
opts = { slowms: opts };
|
|
800
844
|
}
|
|
845
|
+
this._emitDatabaseApiCall('setProfilingLevel', { opts: opts });
|
|
846
|
+
return await this._runCommand({
|
|
847
|
+
profile: level,
|
|
848
|
+
...opts,
|
|
849
|
+
});
|
|
801
850
|
}
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
return await this._getLastErrorObj(w, wTimeout, j);
|
|
812
|
-
}
|
|
813
|
-
async getLastError(w, wTimeout) {
|
|
814
|
-
await this._instanceState.printDeprecationWarning('Database.getLastError() is deprecated and will be removed in the future.');
|
|
815
|
-
this._emitDatabaseApiCall('getLastError', { w: w, wTimeout: wTimeout });
|
|
816
|
-
const result = await this._getLastErrorObj(w, wTimeout);
|
|
817
|
-
return result.err || null;
|
|
818
|
-
}
|
|
819
|
-
async printShardingStatus(verbose = false) {
|
|
820
|
-
this._emitDatabaseApiCall('printShardingStatus', { verbose });
|
|
821
|
-
const result = await (0, helpers_1.getPrintableShardStatus)(await (0, helpers_1.getConfigDB)(this), verbose);
|
|
822
|
-
return new index_1.CommandResult('StatsResult', result);
|
|
823
|
-
}
|
|
824
|
-
async printSecondaryReplicationInfo() {
|
|
825
|
-
let startOptimeDate = null;
|
|
826
|
-
const local = this.getSiblingDB('local');
|
|
827
|
-
if ((await local.getCollection('system.replset').countDocuments({})) !== 0) {
|
|
828
|
-
const status = await this._runAdminCommand({ replSetGetStatus: 1 });
|
|
829
|
-
let primary = null;
|
|
830
|
-
for (const member of status.members) {
|
|
831
|
-
if (member.state === 1) {
|
|
832
|
-
primary = member;
|
|
833
|
-
break;
|
|
834
|
-
}
|
|
851
|
+
async setLogLevel(logLevel, component) {
|
|
852
|
+
(0, helpers_1.assertArgsDefinedType)([logLevel], ['number'], 'Database.setLogLevel');
|
|
853
|
+
this._emitDatabaseApiCall('setLogLevel', {
|
|
854
|
+
logLevel: logLevel,
|
|
855
|
+
component: component,
|
|
856
|
+
});
|
|
857
|
+
let componentNames = [];
|
|
858
|
+
if (typeof component === 'string') {
|
|
859
|
+
componentNames = component.split('.');
|
|
835
860
|
}
|
|
836
|
-
if (
|
|
837
|
-
|
|
861
|
+
else if (component !== undefined) {
|
|
862
|
+
throw new errors_1.MongoshInvalidInputError(`setLogLevel component must be a string: got ${typeof component}`, errors_1.CommonErrors.InvalidArgument);
|
|
838
863
|
}
|
|
839
|
-
|
|
840
|
-
|
|
864
|
+
let vDoc = { verbosity: logLevel };
|
|
865
|
+
while (componentNames.length > 0) {
|
|
866
|
+
const key = componentNames.pop();
|
|
867
|
+
vDoc = { [key]: vDoc };
|
|
868
|
+
}
|
|
869
|
+
const cmdObj = { setParameter: 1, logComponentVerbosity: vDoc };
|
|
870
|
+
return await this._runAdminCommand(cmdObj);
|
|
871
|
+
}
|
|
872
|
+
async getLogComponents() {
|
|
873
|
+
this._emitDatabaseApiCall('getLogComponents', {});
|
|
874
|
+
const cmdObj = { getParameter: 1, logComponentVerbosity: 1 };
|
|
875
|
+
const result = await this._runAdminCommand(cmdObj);
|
|
876
|
+
if (!result || result.logComponentVerbosity === undefined) {
|
|
877
|
+
throw new errors_1.MongoshRuntimeError(`Error running command ${result ? result.errmsg || '' : ''}`, errors_1.CommonErrors.CommandFailed);
|
|
878
|
+
}
|
|
879
|
+
return result.logComponentVerbosity;
|
|
880
|
+
}
|
|
881
|
+
cloneDatabase() {
|
|
882
|
+
throw new errors_1.MongoshDeprecatedError('`cloneDatabase()` was removed because it was deprecated in MongoDB 4.0');
|
|
883
|
+
}
|
|
884
|
+
cloneCollection() {
|
|
885
|
+
throw new errors_1.MongoshDeprecatedError('`cloneCollection()` was removed because it was deprecated in MongoDB 4.0');
|
|
886
|
+
}
|
|
887
|
+
copyDatabase() {
|
|
888
|
+
throw new errors_1.MongoshDeprecatedError('`copyDatabase()` was removed because it was deprecated in MongoDB 4.0');
|
|
889
|
+
}
|
|
890
|
+
async commandHelp(name) {
|
|
891
|
+
(0, helpers_1.assertArgsDefinedType)([name], ['string'], 'Database.commandHelp');
|
|
892
|
+
this._emitDatabaseApiCall('commandHelp', { name: name });
|
|
893
|
+
const command = {};
|
|
894
|
+
command[name] = 1;
|
|
895
|
+
command.help = true;
|
|
896
|
+
const result = await this._runCommand(command);
|
|
897
|
+
if (!result || result.help === undefined) {
|
|
898
|
+
throw new errors_1.MongoshRuntimeError(`Error running command commandHelp ${result ? result.errmsg || '' : ''}`, errors_1.CommonErrors.CommandFailed);
|
|
899
|
+
}
|
|
900
|
+
return result.help;
|
|
901
|
+
}
|
|
902
|
+
async listCommands() {
|
|
903
|
+
this._emitDatabaseApiCall('listCommands', {});
|
|
904
|
+
const result = await this._runReadCommand({
|
|
905
|
+
listCommands: 1,
|
|
906
|
+
});
|
|
907
|
+
if (!result || result.commands === undefined) {
|
|
908
|
+
throw new errors_1.MongoshRuntimeError(`Error running command listCommands ${result ? result.errmsg || '' : ''}`, errors_1.CommonErrors.CommandFailed);
|
|
909
|
+
}
|
|
910
|
+
for (const cmdDescription of Object.values(result.commands)) {
|
|
911
|
+
if ('slaveOk' in cmdDescription) {
|
|
912
|
+
cmdDescription.secondaryOk = cmdDescription.slaveOk;
|
|
913
|
+
delete cmdDescription.slaveOk;
|
|
914
|
+
}
|
|
915
|
+
if ('slaveOverrideOk' in cmdDescription) {
|
|
916
|
+
cmdDescription.secondaryOverrideOk = cmdDescription.slaveOverrideOk;
|
|
917
|
+
delete cmdDescription.slaveOverrideOk;
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
return new index_1.CommandResult('ListCommandsResult', result.commands);
|
|
921
|
+
}
|
|
922
|
+
async getLastErrorObj(w, wTimeout, j) {
|
|
923
|
+
await this._instanceState.printDeprecationWarning('Database.getLastErrorObj() is deprecated and will be removed in the future.');
|
|
924
|
+
this._emitDatabaseApiCall('getLastErrorObj', {
|
|
925
|
+
w: w,
|
|
926
|
+
wTimeout: wTimeout,
|
|
927
|
+
j: j,
|
|
928
|
+
});
|
|
929
|
+
return await this._getLastErrorObj(w, wTimeout, j);
|
|
930
|
+
}
|
|
931
|
+
async getLastError(w, wTimeout) {
|
|
932
|
+
await this._instanceState.printDeprecationWarning('Database.getLastError() is deprecated and will be removed in the future.');
|
|
933
|
+
this._emitDatabaseApiCall('getLastError', { w: w, wTimeout: wTimeout });
|
|
934
|
+
const result = await this._getLastErrorObj(w, wTimeout);
|
|
935
|
+
return result.err || null;
|
|
936
|
+
}
|
|
937
|
+
async printShardingStatus(verbose = false) {
|
|
938
|
+
this._emitDatabaseApiCall('printShardingStatus', { verbose });
|
|
939
|
+
const result = await (0, helpers_1.getPrintableShardStatus)(await (0, helpers_1.getConfigDB)(this), verbose);
|
|
940
|
+
return new index_1.CommandResult('StatsResult', result);
|
|
941
|
+
}
|
|
942
|
+
async printSecondaryReplicationInfo() {
|
|
943
|
+
let startOptimeDate = null;
|
|
944
|
+
const local = this.getSiblingDB('local');
|
|
945
|
+
if ((await local.getCollection('system.replset').countDocuments({})) !== 0) {
|
|
946
|
+
const status = await this._runAdminCommand({ replSetGetStatus: 1 });
|
|
947
|
+
let primary = null;
|
|
841
948
|
for (const member of status.members) {
|
|
842
|
-
if (member.
|
|
843
|
-
|
|
949
|
+
if (member.state === 1) {
|
|
950
|
+
primary = member;
|
|
951
|
+
break;
|
|
844
952
|
}
|
|
845
953
|
}
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
for (const node of status.members) {
|
|
849
|
-
const nodeResult = {};
|
|
850
|
-
if (node === null || node === undefined) {
|
|
851
|
-
throw new errors_1.MongoshRuntimeError('Member returned from command replSetGetStatus is null', errors_1.CommonErrors.CommandFailed);
|
|
954
|
+
if (primary) {
|
|
955
|
+
startOptimeDate = primary.optimeDate;
|
|
852
956
|
}
|
|
853
|
-
|
|
854
|
-
|
|
957
|
+
else {
|
|
958
|
+
startOptimeDate = new Date(0, 0);
|
|
959
|
+
for (const member of status.members) {
|
|
960
|
+
if (member.optimeDate > startOptimeDate) {
|
|
961
|
+
startOptimeDate = member.optimeDate;
|
|
962
|
+
}
|
|
963
|
+
}
|
|
855
964
|
}
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
965
|
+
const result = {};
|
|
966
|
+
for (const node of status.members) {
|
|
967
|
+
const nodeResult = {};
|
|
968
|
+
if (node === null || node === undefined) {
|
|
969
|
+
throw new errors_1.MongoshRuntimeError('Member returned from command replSetGetStatus is null', errors_1.CommonErrors.CommandFailed);
|
|
859
970
|
}
|
|
860
|
-
if (
|
|
861
|
-
|
|
971
|
+
if (node.state === 1 || node.state === 7) {
|
|
972
|
+
continue;
|
|
862
973
|
}
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
974
|
+
if (node.optime && node.health !== 0) {
|
|
975
|
+
if (startOptimeDate === null || startOptimeDate === undefined) {
|
|
976
|
+
throw new errors_1.MongoshRuntimeError('getReplLag startOptimeDate is null', errors_1.CommonErrors.CommandFailed);
|
|
977
|
+
}
|
|
978
|
+
if (startOptimeDate) {
|
|
979
|
+
nodeResult.syncedTo = node.optimeDate.toString();
|
|
980
|
+
}
|
|
981
|
+
const ago = (node.optimeDate - startOptimeDate) / 1000;
|
|
982
|
+
const hrs = Math.round(ago / 36) / 100;
|
|
983
|
+
let suffix = '';
|
|
984
|
+
if (primary) {
|
|
985
|
+
suffix = 'primary ';
|
|
986
|
+
}
|
|
987
|
+
else {
|
|
988
|
+
suffix = 'freshest member (no primary available at the moment)';
|
|
989
|
+
}
|
|
990
|
+
nodeResult.replLag = `${Math.round(ago)} secs (${hrs} hrs) behind the ${suffix}`;
|
|
868
991
|
}
|
|
869
992
|
else {
|
|
870
|
-
|
|
993
|
+
nodeResult['no replication info, yet. State'] = node.stateStr;
|
|
871
994
|
}
|
|
872
|
-
|
|
995
|
+
result[`source: ${node.name}`] = nodeResult;
|
|
873
996
|
}
|
|
874
|
-
|
|
875
|
-
|
|
997
|
+
return new index_1.CommandResult('StatsResult', result);
|
|
998
|
+
}
|
|
999
|
+
throw new errors_1.MongoshInvalidInputError('local.system.replset is empty. Are you connected to a replica set?', error_codes_1.ShellApiErrors.NotConnectedToReplicaSet);
|
|
1000
|
+
}
|
|
1001
|
+
async getReplicationInfo() {
|
|
1002
|
+
const localdb = this.getSiblingDB('local');
|
|
1003
|
+
const result = {};
|
|
1004
|
+
const oplog = 'oplog.rs';
|
|
1005
|
+
const localCollections = await localdb.getCollectionNames();
|
|
1006
|
+
if (!localCollections.includes(oplog)) {
|
|
1007
|
+
throw new errors_1.MongoshInvalidInputError('Replication not detected. Are you connected to a replset?', error_codes_1.ShellApiErrors.NotConnectedToReplicaSet);
|
|
1008
|
+
}
|
|
1009
|
+
const ol = localdb.getCollection(oplog);
|
|
1010
|
+
const [olStats, first, last] = await Promise.all([
|
|
1011
|
+
ol.stats(),
|
|
1012
|
+
(async () => (await ol.find()).sort({ $natural: 1 }).limit(1).tryNext())(),
|
|
1013
|
+
(async () => (await ol.find()).sort({ $natural: -1 }).limit(1).tryNext())(),
|
|
1014
|
+
]);
|
|
1015
|
+
if (!(olStats === null || olStats === void 0 ? void 0 : olStats.maxSize)) {
|
|
1016
|
+
throw new errors_1.MongoshRuntimeError(`Could not get stats for local.${oplog} collection. collstats returned ${JSON.stringify(olStats)}`, errors_1.CommonErrors.CommandFailed);
|
|
1017
|
+
}
|
|
1018
|
+
result.configuredLogSizeMB = olStats.maxSize / (1024 * 1024);
|
|
1019
|
+
result.logSizeMB = Math.max(olStats.maxSize, olStats.size) / (1024 * 1024);
|
|
1020
|
+
result.usedMB = olStats.size / (1024 * 1024);
|
|
1021
|
+
result.usedMB = Math.ceil(result.usedMB * 100) / 100;
|
|
1022
|
+
if (first === null || last === null) {
|
|
1023
|
+
throw new errors_1.MongoshRuntimeError('objects not found in local.oplog.$main -- is this a new and empty db instance?', errors_1.CommonErrors.CommandFailed);
|
|
1024
|
+
}
|
|
1025
|
+
let tfirst = first.ts;
|
|
1026
|
+
let tlast = last.ts;
|
|
1027
|
+
if (tfirst && tlast) {
|
|
1028
|
+
tfirst = (0, helpers_1.tsToSeconds)(tfirst);
|
|
1029
|
+
tlast = (0, helpers_1.tsToSeconds)(tlast);
|
|
1030
|
+
result.timeDiff = tlast - tfirst;
|
|
1031
|
+
result.timeDiffHours = Math.round(result.timeDiff / 36) / 100;
|
|
1032
|
+
result.tFirst = new Date(tfirst * 1000).toString();
|
|
1033
|
+
result.tLast = new Date(tlast * 1000).toString();
|
|
1034
|
+
result.now = Date();
|
|
1035
|
+
}
|
|
1036
|
+
else {
|
|
1037
|
+
result.errmsg = 'ts element not found in oplog objects';
|
|
1038
|
+
}
|
|
1039
|
+
return result;
|
|
1040
|
+
}
|
|
1041
|
+
async printReplicationInfo() {
|
|
1042
|
+
const result = {};
|
|
1043
|
+
let replInfo;
|
|
1044
|
+
try {
|
|
1045
|
+
replInfo = await this.getReplicationInfo();
|
|
1046
|
+
}
|
|
1047
|
+
catch (error) {
|
|
1048
|
+
const helloResult = await this.hello();
|
|
1049
|
+
if (helloResult.arbiterOnly) {
|
|
1050
|
+
return new index_1.CommandResult('StatsResult', {
|
|
1051
|
+
message: 'cannot provide replication status from an arbiter',
|
|
1052
|
+
});
|
|
1053
|
+
}
|
|
1054
|
+
else if (!helloResult.isWritablePrimary) {
|
|
1055
|
+
const secondaryInfo = await this.printSecondaryReplicationInfo();
|
|
1056
|
+
return new index_1.CommandResult('StatsResult', {
|
|
1057
|
+
message: 'this is a secondary, printing secondary replication info.',
|
|
1058
|
+
...secondaryInfo.value,
|
|
1059
|
+
});
|
|
876
1060
|
}
|
|
877
|
-
|
|
1061
|
+
throw error;
|
|
878
1062
|
}
|
|
1063
|
+
result['actual oplog size'] = `${replInfo.logSizeMB} MB`;
|
|
1064
|
+
result['configured oplog size'] = `${replInfo.configuredLogSizeMB} MB`;
|
|
1065
|
+
result['log length start to end'] = `${replInfo.timeDiff} secs (${replInfo.timeDiffHours} hrs)`;
|
|
1066
|
+
result['oplog first event time'] = replInfo.tFirst;
|
|
1067
|
+
result['oplog last event time'] = replInfo.tLast;
|
|
1068
|
+
result.now = replInfo.now;
|
|
879
1069
|
return new index_1.CommandResult('StatsResult', result);
|
|
880
1070
|
}
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
const ol = localdb.getCollection(oplog);
|
|
892
|
-
const [olStats, first, last] = await Promise.all([
|
|
893
|
-
ol.stats(),
|
|
894
|
-
(async () => (await ol.find()).sort({ $natural: 1 }).limit(1).tryNext())(),
|
|
895
|
-
(async () => (await ol.find()).sort({ $natural: -1 }).limit(1).tryNext())(),
|
|
896
|
-
]);
|
|
897
|
-
if (!(olStats === null || olStats === void 0 ? void 0 : olStats.maxSize)) {
|
|
898
|
-
throw new errors_1.MongoshRuntimeError(`Could not get stats for local.${oplog} collection. collstats returned ${JSON.stringify(olStats)}`, errors_1.CommonErrors.CommandFailed);
|
|
899
|
-
}
|
|
900
|
-
result.configuredLogSizeMB = olStats.maxSize / (1024 * 1024);
|
|
901
|
-
result.logSizeMB = Math.max(olStats.maxSize, olStats.size) / (1024 * 1024);
|
|
902
|
-
result.usedMB = olStats.size / (1024 * 1024);
|
|
903
|
-
result.usedMB = Math.ceil(result.usedMB * 100) / 100;
|
|
904
|
-
if (first === null || last === null) {
|
|
905
|
-
throw new errors_1.MongoshRuntimeError('objects not found in local.oplog.$main -- is this a new and empty db instance?', errors_1.CommonErrors.CommandFailed);
|
|
906
|
-
}
|
|
907
|
-
let tfirst = first.ts;
|
|
908
|
-
let tlast = last.ts;
|
|
909
|
-
if (tfirst && tlast) {
|
|
910
|
-
tfirst = (0, helpers_1.tsToSeconds)(tfirst);
|
|
911
|
-
tlast = (0, helpers_1.tsToSeconds)(tlast);
|
|
912
|
-
result.timeDiff = tlast - tfirst;
|
|
913
|
-
result.timeDiffHours = Math.round(result.timeDiff / 36) / 100;
|
|
914
|
-
result.tFirst = new Date(tfirst * 1000).toString();
|
|
915
|
-
result.tLast = new Date(tlast * 1000).toString();
|
|
916
|
-
result.now = Date();
|
|
917
|
-
}
|
|
918
|
-
else {
|
|
919
|
-
result.errmsg = 'ts element not found in oplog objects';
|
|
920
|
-
}
|
|
921
|
-
return result;
|
|
922
|
-
}
|
|
923
|
-
async printReplicationInfo() {
|
|
924
|
-
const result = {};
|
|
925
|
-
let replInfo;
|
|
926
|
-
try {
|
|
927
|
-
replInfo = await this.getReplicationInfo();
|
|
928
|
-
}
|
|
929
|
-
catch (error) {
|
|
930
|
-
const helloResult = await this.hello();
|
|
931
|
-
if (helloResult.arbiterOnly) {
|
|
932
|
-
return new index_1.CommandResult('StatsResult', {
|
|
933
|
-
message: 'cannot provide replication status from an arbiter',
|
|
934
|
-
});
|
|
1071
|
+
printSlaveReplicationInfo() {
|
|
1072
|
+
throw new errors_1.MongoshDeprecatedError('Method deprecated, use db.printSecondaryReplicationInfo instead');
|
|
1073
|
+
}
|
|
1074
|
+
async setSecondaryOk() {
|
|
1075
|
+
await this._mongo.setSecondaryOk();
|
|
1076
|
+
}
|
|
1077
|
+
async watch(pipeline = [], options = {}) {
|
|
1078
|
+
if (!Array.isArray(pipeline)) {
|
|
1079
|
+
options = pipeline;
|
|
1080
|
+
pipeline = [];
|
|
935
1081
|
}
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
1082
|
+
this._emitDatabaseApiCall('watch', { pipeline, options });
|
|
1083
|
+
const cursor = new change_stream_cursor_1.default(this._mongo._serviceProvider.watch(pipeline, {
|
|
1084
|
+
...(await this._baseOptions()),
|
|
1085
|
+
...options,
|
|
1086
|
+
}, {}, this._name), this._name, this._mongo);
|
|
1087
|
+
if (!options.resumeAfter &&
|
|
1088
|
+
!options.startAfter &&
|
|
1089
|
+
!options.startAtOperationTime) {
|
|
1090
|
+
await cursor.tryNext();
|
|
942
1091
|
}
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
}
|
|
959
|
-
async watch(pipeline = [], options = {}) {
|
|
960
|
-
if (!Array.isArray(pipeline)) {
|
|
961
|
-
options = pipeline;
|
|
962
|
-
pipeline = [];
|
|
963
|
-
}
|
|
964
|
-
this._emitDatabaseApiCall('watch', { pipeline, options });
|
|
965
|
-
const cursor = new change_stream_cursor_1.default(this._mongo._serviceProvider.watch(pipeline, {
|
|
966
|
-
...(await this._baseOptions()),
|
|
967
|
-
...options,
|
|
968
|
-
}, {}, this._name), this._name, this._mongo);
|
|
969
|
-
if (!options.resumeAfter &&
|
|
970
|
-
!options.startAfter &&
|
|
971
|
-
!options.startAtOperationTime) {
|
|
972
|
-
await cursor.tryNext();
|
|
973
|
-
}
|
|
974
|
-
this._mongo._instanceState.currentCursor = cursor;
|
|
975
|
-
return cursor;
|
|
976
|
-
}
|
|
977
|
-
async sql(sqlString, options) {
|
|
978
|
-
var _a;
|
|
979
|
-
this._emitDatabaseApiCall('sql', { sqlString: sqlString, options });
|
|
980
|
-
await this._instanceState.shellApi.print('Note: this is an experimental feature that may be subject to change in future releases.');
|
|
981
|
-
const cursor = await this.aggregate([
|
|
982
|
-
{
|
|
983
|
-
$sql: {
|
|
984
|
-
statement: sqlString,
|
|
985
|
-
format: 'jdbc',
|
|
986
|
-
dialect: 'mongosql',
|
|
987
|
-
formatVersion: 1,
|
|
1092
|
+
this._mongo._instanceState.currentCursor = cursor;
|
|
1093
|
+
return cursor;
|
|
1094
|
+
}
|
|
1095
|
+
async sql(sqlString, options) {
|
|
1096
|
+
var _a;
|
|
1097
|
+
this._emitDatabaseApiCall('sql', { sqlString: sqlString, options });
|
|
1098
|
+
await this._instanceState.shellApi.print('Note: this is an experimental feature that may be subject to change in future releases.');
|
|
1099
|
+
const cursor = await this.aggregate([
|
|
1100
|
+
{
|
|
1101
|
+
$sql: {
|
|
1102
|
+
statement: sqlString,
|
|
1103
|
+
format: 'jdbc',
|
|
1104
|
+
dialect: 'mongosql',
|
|
1105
|
+
formatVersion: 1,
|
|
1106
|
+
},
|
|
988
1107
|
},
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
await cursor.hasNext();
|
|
993
|
-
}
|
|
994
|
-
catch (err) {
|
|
995
|
-
if (((_a = err.code) === null || _a === void 0 ? void 0 : _a.valueOf()) === 40324) {
|
|
996
|
-
throw new errors_1.MongoshRuntimeError('db.sql currently only works when connected to a Data Lake', errors_1.CommonErrors.CommandFailed);
|
|
1108
|
+
], options);
|
|
1109
|
+
try {
|
|
1110
|
+
await cursor.hasNext();
|
|
997
1111
|
}
|
|
998
|
-
|
|
1112
|
+
catch (err) {
|
|
1113
|
+
if (((_a = err.code) === null || _a === void 0 ? void 0 : _a.valueOf()) === 40324) {
|
|
1114
|
+
throw new errors_1.MongoshRuntimeError('db.sql currently only works when connected to a Data Lake', errors_1.CommonErrors.CommandFailed);
|
|
1115
|
+
}
|
|
1116
|
+
throw err;
|
|
1117
|
+
}
|
|
1118
|
+
return cursor;
|
|
999
1119
|
}
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
],
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
], Database.prototype, "fsyncUnlock", null);
|
|
1157
|
-
__decorate([
|
|
1158
|
-
decorators_1.returnsPromise,
|
|
1159
|
-
(0, decorators_1.apiVersions)([])
|
|
1160
|
-
], Database.prototype, "version", null);
|
|
1161
|
-
__decorate([
|
|
1162
|
-
decorators_1.returnsPromise,
|
|
1163
|
-
(0, decorators_1.apiVersions)([])
|
|
1164
|
-
], Database.prototype, "serverBits", null);
|
|
1165
|
-
__decorate([
|
|
1166
|
-
decorators_1.returnsPromise,
|
|
1167
|
-
(0, decorators_1.apiVersions)([])
|
|
1168
|
-
], Database.prototype, "isMaster", null);
|
|
1169
|
-
__decorate([
|
|
1170
|
-
decorators_1.returnsPromise,
|
|
1171
|
-
(0, decorators_1.apiVersions)([1]),
|
|
1172
|
-
(0, decorators_1.serverVersions)(['5.0.0', enums_1.ServerVersions.latest])
|
|
1173
|
-
], Database.prototype, "hello", null);
|
|
1174
|
-
__decorate([
|
|
1175
|
-
decorators_1.returnsPromise,
|
|
1176
|
-
(0, decorators_1.apiVersions)([])
|
|
1177
|
-
], Database.prototype, "serverBuildInfo", null);
|
|
1178
|
-
__decorate([
|
|
1179
|
-
decorators_1.returnsPromise,
|
|
1180
|
-
(0, decorators_1.apiVersions)([])
|
|
1181
|
-
], Database.prototype, "serverStatus", null);
|
|
1182
|
-
__decorate([
|
|
1183
|
-
decorators_1.returnsPromise,
|
|
1184
|
-
(0, decorators_1.apiVersions)([])
|
|
1185
|
-
], Database.prototype, "stats", null);
|
|
1186
|
-
__decorate([
|
|
1187
|
-
decorators_1.returnsPromise,
|
|
1188
|
-
(0, decorators_1.apiVersions)([])
|
|
1189
|
-
], Database.prototype, "hostInfo", null);
|
|
1190
|
-
__decorate([
|
|
1191
|
-
decorators_1.returnsPromise,
|
|
1192
|
-
(0, decorators_1.apiVersions)([])
|
|
1193
|
-
], Database.prototype, "serverCmdLineOpts", null);
|
|
1194
|
-
__decorate([
|
|
1195
|
-
decorators_1.returnsPromise,
|
|
1196
|
-
(0, decorators_1.serverVersions)(['5.0.0', enums_1.ServerVersions.latest]),
|
|
1197
|
-
(0, decorators_1.apiVersions)([])
|
|
1198
|
-
], Database.prototype, "rotateCertificates", null);
|
|
1199
|
-
__decorate([
|
|
1200
|
-
decorators_1.returnsPromise,
|
|
1201
|
-
(0, decorators_1.apiVersions)([])
|
|
1202
|
-
], Database.prototype, "printCollectionStats", null);
|
|
1203
|
-
__decorate([
|
|
1204
|
-
decorators_1.returnsPromise,
|
|
1205
|
-
(0, decorators_1.apiVersions)([])
|
|
1206
|
-
], Database.prototype, "getProfilingStatus", null);
|
|
1207
|
-
__decorate([
|
|
1208
|
-
decorators_1.returnsPromise,
|
|
1209
|
-
(0, decorators_1.apiVersions)([])
|
|
1210
|
-
], Database.prototype, "setProfilingLevel", null);
|
|
1211
|
-
__decorate([
|
|
1212
|
-
decorators_1.returnsPromise,
|
|
1213
|
-
(0, decorators_1.apiVersions)([])
|
|
1214
|
-
], Database.prototype, "setLogLevel", null);
|
|
1215
|
-
__decorate([
|
|
1216
|
-
decorators_1.returnsPromise,
|
|
1217
|
-
(0, decorators_1.apiVersions)([])
|
|
1218
|
-
], Database.prototype, "getLogComponents", null);
|
|
1219
|
-
__decorate([
|
|
1220
|
-
decorators_1.deprecated
|
|
1221
|
-
], Database.prototype, "cloneDatabase", null);
|
|
1222
|
-
__decorate([
|
|
1223
|
-
decorators_1.deprecated
|
|
1224
|
-
], Database.prototype, "cloneCollection", null);
|
|
1225
|
-
__decorate([
|
|
1226
|
-
decorators_1.deprecated
|
|
1227
|
-
], Database.prototype, "copyDatabase", null);
|
|
1228
|
-
__decorate([
|
|
1229
|
-
decorators_1.returnsPromise,
|
|
1230
|
-
(0, decorators_1.apiVersions)([1])
|
|
1231
|
-
], Database.prototype, "commandHelp", null);
|
|
1232
|
-
__decorate([
|
|
1233
|
-
decorators_1.returnsPromise,
|
|
1234
|
-
(0, decorators_1.apiVersions)([])
|
|
1235
|
-
], Database.prototype, "listCommands", null);
|
|
1236
|
-
__decorate([
|
|
1237
|
-
(0, decorators_1.serverVersions)([enums_1.ServerVersions.earliest, '5.1.0']),
|
|
1238
|
-
decorators_1.deprecated,
|
|
1239
|
-
decorators_1.returnsPromise,
|
|
1240
|
-
(0, decorators_1.apiVersions)([])
|
|
1241
|
-
], Database.prototype, "getLastErrorObj", null);
|
|
1242
|
-
__decorate([
|
|
1243
|
-
decorators_1.deprecated,
|
|
1244
|
-
decorators_1.returnsPromise,
|
|
1245
|
-
(0, decorators_1.apiVersions)([])
|
|
1246
|
-
], Database.prototype, "getLastError", null);
|
|
1247
|
-
__decorate([
|
|
1248
|
-
decorators_1.returnsPromise,
|
|
1249
|
-
(0, decorators_1.topologies)([enums_1.Topologies.Sharded]),
|
|
1250
|
-
(0, decorators_1.apiVersions)([1])
|
|
1251
|
-
], Database.prototype, "printShardingStatus", null);
|
|
1252
|
-
__decorate([
|
|
1253
|
-
decorators_1.returnsPromise,
|
|
1254
|
-
(0, decorators_1.topologies)([enums_1.Topologies.ReplSet]),
|
|
1255
|
-
(0, decorators_1.apiVersions)([])
|
|
1256
|
-
], Database.prototype, "printSecondaryReplicationInfo", null);
|
|
1257
|
-
__decorate([
|
|
1258
|
-
decorators_1.returnsPromise,
|
|
1259
|
-
(0, decorators_1.topologies)([enums_1.Topologies.ReplSet]),
|
|
1260
|
-
(0, decorators_1.apiVersions)([])
|
|
1261
|
-
], Database.prototype, "getReplicationInfo", null);
|
|
1262
|
-
__decorate([
|
|
1263
|
-
decorators_1.returnsPromise,
|
|
1264
|
-
(0, decorators_1.apiVersions)([]),
|
|
1265
|
-
(0, decorators_1.topologies)([enums_1.Topologies.ReplSet])
|
|
1266
|
-
], Database.prototype, "printReplicationInfo", null);
|
|
1267
|
-
__decorate([
|
|
1268
|
-
decorators_1.deprecated
|
|
1269
|
-
], Database.prototype, "printSlaveReplicationInfo", null);
|
|
1270
|
-
__decorate([
|
|
1271
|
-
decorators_1.deprecated,
|
|
1272
|
-
decorators_1.returnsPromise
|
|
1273
|
-
], Database.prototype, "setSecondaryOk", null);
|
|
1274
|
-
__decorate([
|
|
1275
|
-
(0, decorators_1.serverVersions)(['3.1.0', enums_1.ServerVersions.latest]),
|
|
1276
|
-
(0, decorators_1.topologies)([enums_1.Topologies.ReplSet, enums_1.Topologies.Sharded]),
|
|
1277
|
-
(0, decorators_1.apiVersions)([1]),
|
|
1278
|
-
decorators_1.returnsPromise
|
|
1279
|
-
], Database.prototype, "watch", null);
|
|
1280
|
-
__decorate([
|
|
1281
|
-
(0, decorators_1.serverVersions)(['4.4.0', enums_1.ServerVersions.latest]),
|
|
1282
|
-
decorators_1.returnsPromise,
|
|
1283
|
-
(0, decorators_1.returnType)('AggregationCursor')
|
|
1284
|
-
], Database.prototype, "sql", null);
|
|
1285
|
-
__decorate([
|
|
1286
|
-
(0, decorators_1.serverVersions)(['7.0.0', enums_1.ServerVersions.latest]),
|
|
1287
|
-
(0, decorators_1.topologies)([enums_1.Topologies.Sharded]),
|
|
1288
|
-
decorators_1.returnsPromise
|
|
1289
|
-
], Database.prototype, "checkMetadataConsistency", null);
|
|
1290
|
-
Database = __decorate([
|
|
1291
|
-
decorators_1.shellApiClassDefault
|
|
1292
|
-
], Database);
|
|
1120
|
+
async checkMetadataConsistency(options = {}) {
|
|
1121
|
+
this._emitDatabaseApiCall('checkMetadataConsistency', { options });
|
|
1122
|
+
return this._runCursorCommand({
|
|
1123
|
+
checkMetadataConsistency: 1,
|
|
1124
|
+
});
|
|
1125
|
+
}
|
|
1126
|
+
};
|
|
1127
|
+
__setFunctionName(_classThis, "Database");
|
|
1128
|
+
(() => {
|
|
1129
|
+
var _a;
|
|
1130
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0;
|
|
1131
|
+
_getMongo_decorators = [(0, decorators_1.returnType)('Mongo')];
|
|
1132
|
+
_getCollectionNames_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([1])];
|
|
1133
|
+
_getCollectionInfos_decorators = [decorators_1.returnsPromise, (0, decorators_1.serverVersions)(['3.0.0', enums_1.ServerVersions.latest]), (0, decorators_1.apiVersions)([1])];
|
|
1134
|
+
_runCommand_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([1])];
|
|
1135
|
+
_adminCommand_decorators = [decorators_1.returnsPromise, (0, decorators_1.serverVersions)(['3.4.0', enums_1.ServerVersions.latest]), (0, decorators_1.apiVersions)([1])];
|
|
1136
|
+
_aggregate_decorators = [decorators_1.returnsPromise, (0, decorators_1.returnType)('AggregationCursor'), (0, decorators_1.apiVersions)([1])];
|
|
1137
|
+
_getSiblingDB_decorators = [(0, decorators_1.returnType)('Database')];
|
|
1138
|
+
_getCollection_decorators = [(0, decorators_1.returnType)('Collection')];
|
|
1139
|
+
_dropDatabase_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([1])];
|
|
1140
|
+
_createUser_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1141
|
+
_updateUser_decorators = [decorators_1.returnsPromise];
|
|
1142
|
+
_changeUserPassword_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1143
|
+
_logout_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1144
|
+
_dropUser_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1145
|
+
_dropAllUsers_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1146
|
+
_auth_decorators = [decorators_1.returnsPromise];
|
|
1147
|
+
_grantRolesToUser_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1148
|
+
_revokeRolesFromUser_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1149
|
+
_getUser_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1150
|
+
_getUsers_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1151
|
+
_createCollection_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([1])];
|
|
1152
|
+
_createEncryptedCollection_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([1])];
|
|
1153
|
+
_createView_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([1])];
|
|
1154
|
+
_createRole_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1155
|
+
_updateRole_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1156
|
+
_dropRole_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1157
|
+
_dropAllRoles_decorators = [decorators_1.returnsPromise];
|
|
1158
|
+
_grantRolesToRole_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1159
|
+
_revokeRolesFromRole_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1160
|
+
_grantPrivilegesToRole_decorators = [decorators_1.returnsPromise];
|
|
1161
|
+
_revokePrivilegesFromRole_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1162
|
+
_getRole_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1163
|
+
_getRoles_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1164
|
+
_currentOp_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1165
|
+
_killOp_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1166
|
+
_shutdownServer_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1167
|
+
_fsyncLock_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1168
|
+
_fsyncUnlock_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1169
|
+
_version_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1170
|
+
_serverBits_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1171
|
+
_isMaster_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1172
|
+
_hello_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([1]), (0, decorators_1.serverVersions)(['5.0.0', enums_1.ServerVersions.latest])];
|
|
1173
|
+
_serverBuildInfo_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1174
|
+
_serverStatus_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1175
|
+
_stats_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1176
|
+
_hostInfo_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1177
|
+
_serverCmdLineOpts_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1178
|
+
_rotateCertificates_decorators = [decorators_1.returnsPromise, (0, decorators_1.serverVersions)(['5.0.0', enums_1.ServerVersions.latest]), (0, decorators_1.apiVersions)([])];
|
|
1179
|
+
_printCollectionStats_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1180
|
+
_getProfilingStatus_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1181
|
+
_setProfilingLevel_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1182
|
+
_setLogLevel_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1183
|
+
_getLogComponents_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1184
|
+
_cloneDatabase_decorators = [decorators_1.deprecated];
|
|
1185
|
+
_cloneCollection_decorators = [decorators_1.deprecated];
|
|
1186
|
+
_copyDatabase_decorators = [decorators_1.deprecated];
|
|
1187
|
+
_commandHelp_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([1])];
|
|
1188
|
+
_listCommands_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1189
|
+
_getLastErrorObj_decorators = [(0, decorators_1.serverVersions)([enums_1.ServerVersions.earliest, '5.1.0']), decorators_1.deprecated, decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1190
|
+
_getLastError_decorators = [decorators_1.deprecated, decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
|
|
1191
|
+
_printShardingStatus_decorators = [decorators_1.returnsPromise, (0, decorators_1.topologies)([enums_1.Topologies.Sharded]), (0, decorators_1.apiVersions)([1])];
|
|
1192
|
+
_printSecondaryReplicationInfo_decorators = [decorators_1.returnsPromise, (0, decorators_1.topologies)([enums_1.Topologies.ReplSet]), (0, decorators_1.apiVersions)([])];
|
|
1193
|
+
_getReplicationInfo_decorators = [decorators_1.returnsPromise, (0, decorators_1.topologies)([enums_1.Topologies.ReplSet]), (0, decorators_1.apiVersions)([])];
|
|
1194
|
+
_printReplicationInfo_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([]), (0, decorators_1.topologies)([enums_1.Topologies.ReplSet])];
|
|
1195
|
+
_printSlaveReplicationInfo_decorators = [decorators_1.deprecated];
|
|
1196
|
+
_setSecondaryOk_decorators = [decorators_1.deprecated, decorators_1.returnsPromise];
|
|
1197
|
+
_watch_decorators = [(0, decorators_1.serverVersions)(['3.1.0', enums_1.ServerVersions.latest]), (0, decorators_1.topologies)([enums_1.Topologies.ReplSet, enums_1.Topologies.Sharded]), (0, decorators_1.apiVersions)([1]), decorators_1.returnsPromise];
|
|
1198
|
+
_sql_decorators = [(0, decorators_1.serverVersions)(['4.4.0', enums_1.ServerVersions.latest]), decorators_1.returnsPromise, (0, decorators_1.returnType)('AggregationCursor')];
|
|
1199
|
+
_checkMetadataConsistency_decorators = [(0, decorators_1.serverVersions)(['7.0.0', enums_1.ServerVersions.latest]), (0, decorators_1.topologies)([enums_1.Topologies.Sharded]), decorators_1.returnsPromise];
|
|
1200
|
+
__esDecorate(_classThis, null, _getMongo_decorators, { kind: "method", name: "getMongo", static: false, private: false, access: { has: obj => "getMongo" in obj, get: obj => obj.getMongo }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1201
|
+
__esDecorate(_classThis, null, _getCollectionNames_decorators, { kind: "method", name: "getCollectionNames", static: false, private: false, access: { has: obj => "getCollectionNames" in obj, get: obj => obj.getCollectionNames }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1202
|
+
__esDecorate(_classThis, null, _getCollectionInfos_decorators, { kind: "method", name: "getCollectionInfos", static: false, private: false, access: { has: obj => "getCollectionInfos" in obj, get: obj => obj.getCollectionInfos }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1203
|
+
__esDecorate(_classThis, null, _runCommand_decorators, { kind: "method", name: "runCommand", static: false, private: false, access: { has: obj => "runCommand" in obj, get: obj => obj.runCommand }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1204
|
+
__esDecorate(_classThis, null, _adminCommand_decorators, { kind: "method", name: "adminCommand", static: false, private: false, access: { has: obj => "adminCommand" in obj, get: obj => obj.adminCommand }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1205
|
+
__esDecorate(_classThis, null, _aggregate_decorators, { kind: "method", name: "aggregate", static: false, private: false, access: { has: obj => "aggregate" in obj, get: obj => obj.aggregate }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1206
|
+
__esDecorate(_classThis, null, _getSiblingDB_decorators, { kind: "method", name: "getSiblingDB", static: false, private: false, access: { has: obj => "getSiblingDB" in obj, get: obj => obj.getSiblingDB }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1207
|
+
__esDecorate(_classThis, null, _getCollection_decorators, { kind: "method", name: "getCollection", static: false, private: false, access: { has: obj => "getCollection" in obj, get: obj => obj.getCollection }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1208
|
+
__esDecorate(_classThis, null, _dropDatabase_decorators, { kind: "method", name: "dropDatabase", static: false, private: false, access: { has: obj => "dropDatabase" in obj, get: obj => obj.dropDatabase }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1209
|
+
__esDecorate(_classThis, null, _createUser_decorators, { kind: "method", name: "createUser", static: false, private: false, access: { has: obj => "createUser" in obj, get: obj => obj.createUser }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1210
|
+
__esDecorate(_classThis, null, _updateUser_decorators, { kind: "method", name: "updateUser", static: false, private: false, access: { has: obj => "updateUser" in obj, get: obj => obj.updateUser }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1211
|
+
__esDecorate(_classThis, null, _changeUserPassword_decorators, { kind: "method", name: "changeUserPassword", static: false, private: false, access: { has: obj => "changeUserPassword" in obj, get: obj => obj.changeUserPassword }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1212
|
+
__esDecorate(_classThis, null, _logout_decorators, { kind: "method", name: "logout", static: false, private: false, access: { has: obj => "logout" in obj, get: obj => obj.logout }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1213
|
+
__esDecorate(_classThis, null, _dropUser_decorators, { kind: "method", name: "dropUser", static: false, private: false, access: { has: obj => "dropUser" in obj, get: obj => obj.dropUser }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1214
|
+
__esDecorate(_classThis, null, _dropAllUsers_decorators, { kind: "method", name: "dropAllUsers", static: false, private: false, access: { has: obj => "dropAllUsers" in obj, get: obj => obj.dropAllUsers }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1215
|
+
__esDecorate(_classThis, null, _auth_decorators, { kind: "method", name: "auth", static: false, private: false, access: { has: obj => "auth" in obj, get: obj => obj.auth }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1216
|
+
__esDecorate(_classThis, null, _grantRolesToUser_decorators, { kind: "method", name: "grantRolesToUser", static: false, private: false, access: { has: obj => "grantRolesToUser" in obj, get: obj => obj.grantRolesToUser }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1217
|
+
__esDecorate(_classThis, null, _revokeRolesFromUser_decorators, { kind: "method", name: "revokeRolesFromUser", static: false, private: false, access: { has: obj => "revokeRolesFromUser" in obj, get: obj => obj.revokeRolesFromUser }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1218
|
+
__esDecorate(_classThis, null, _getUser_decorators, { kind: "method", name: "getUser", static: false, private: false, access: { has: obj => "getUser" in obj, get: obj => obj.getUser }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1219
|
+
__esDecorate(_classThis, null, _getUsers_decorators, { kind: "method", name: "getUsers", static: false, private: false, access: { has: obj => "getUsers" in obj, get: obj => obj.getUsers }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1220
|
+
__esDecorate(_classThis, null, _createCollection_decorators, { kind: "method", name: "createCollection", static: false, private: false, access: { has: obj => "createCollection" in obj, get: obj => obj.createCollection }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1221
|
+
__esDecorate(_classThis, null, _createEncryptedCollection_decorators, { kind: "method", name: "createEncryptedCollection", static: false, private: false, access: { has: obj => "createEncryptedCollection" in obj, get: obj => obj.createEncryptedCollection }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1222
|
+
__esDecorate(_classThis, null, _createView_decorators, { kind: "method", name: "createView", static: false, private: false, access: { has: obj => "createView" in obj, get: obj => obj.createView }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1223
|
+
__esDecorate(_classThis, null, _createRole_decorators, { kind: "method", name: "createRole", static: false, private: false, access: { has: obj => "createRole" in obj, get: obj => obj.createRole }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1224
|
+
__esDecorate(_classThis, null, _updateRole_decorators, { kind: "method", name: "updateRole", static: false, private: false, access: { has: obj => "updateRole" in obj, get: obj => obj.updateRole }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1225
|
+
__esDecorate(_classThis, null, _dropRole_decorators, { kind: "method", name: "dropRole", static: false, private: false, access: { has: obj => "dropRole" in obj, get: obj => obj.dropRole }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1226
|
+
__esDecorate(_classThis, null, _dropAllRoles_decorators, { kind: "method", name: "dropAllRoles", static: false, private: false, access: { has: obj => "dropAllRoles" in obj, get: obj => obj.dropAllRoles }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1227
|
+
__esDecorate(_classThis, null, _grantRolesToRole_decorators, { kind: "method", name: "grantRolesToRole", static: false, private: false, access: { has: obj => "grantRolesToRole" in obj, get: obj => obj.grantRolesToRole }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1228
|
+
__esDecorate(_classThis, null, _revokeRolesFromRole_decorators, { kind: "method", name: "revokeRolesFromRole", static: false, private: false, access: { has: obj => "revokeRolesFromRole" in obj, get: obj => obj.revokeRolesFromRole }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1229
|
+
__esDecorate(_classThis, null, _grantPrivilegesToRole_decorators, { kind: "method", name: "grantPrivilegesToRole", static: false, private: false, access: { has: obj => "grantPrivilegesToRole" in obj, get: obj => obj.grantPrivilegesToRole }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1230
|
+
__esDecorate(_classThis, null, _revokePrivilegesFromRole_decorators, { kind: "method", name: "revokePrivilegesFromRole", static: false, private: false, access: { has: obj => "revokePrivilegesFromRole" in obj, get: obj => obj.revokePrivilegesFromRole }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1231
|
+
__esDecorate(_classThis, null, _getRole_decorators, { kind: "method", name: "getRole", static: false, private: false, access: { has: obj => "getRole" in obj, get: obj => obj.getRole }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1232
|
+
__esDecorate(_classThis, null, _getRoles_decorators, { kind: "method", name: "getRoles", static: false, private: false, access: { has: obj => "getRoles" in obj, get: obj => obj.getRoles }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1233
|
+
__esDecorate(_classThis, null, _currentOp_decorators, { kind: "method", name: "currentOp", static: false, private: false, access: { has: obj => "currentOp" in obj, get: obj => obj.currentOp }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1234
|
+
__esDecorate(_classThis, null, _killOp_decorators, { kind: "method", name: "killOp", static: false, private: false, access: { has: obj => "killOp" in obj, get: obj => obj.killOp }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1235
|
+
__esDecorate(_classThis, null, _shutdownServer_decorators, { kind: "method", name: "shutdownServer", static: false, private: false, access: { has: obj => "shutdownServer" in obj, get: obj => obj.shutdownServer }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1236
|
+
__esDecorate(_classThis, null, _fsyncLock_decorators, { kind: "method", name: "fsyncLock", static: false, private: false, access: { has: obj => "fsyncLock" in obj, get: obj => obj.fsyncLock }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1237
|
+
__esDecorate(_classThis, null, _fsyncUnlock_decorators, { kind: "method", name: "fsyncUnlock", static: false, private: false, access: { has: obj => "fsyncUnlock" in obj, get: obj => obj.fsyncUnlock }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1238
|
+
__esDecorate(_classThis, null, _version_decorators, { kind: "method", name: "version", static: false, private: false, access: { has: obj => "version" in obj, get: obj => obj.version }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1239
|
+
__esDecorate(_classThis, null, _serverBits_decorators, { kind: "method", name: "serverBits", static: false, private: false, access: { has: obj => "serverBits" in obj, get: obj => obj.serverBits }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1240
|
+
__esDecorate(_classThis, null, _isMaster_decorators, { kind: "method", name: "isMaster", static: false, private: false, access: { has: obj => "isMaster" in obj, get: obj => obj.isMaster }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1241
|
+
__esDecorate(_classThis, null, _hello_decorators, { kind: "method", name: "hello", static: false, private: false, access: { has: obj => "hello" in obj, get: obj => obj.hello }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1242
|
+
__esDecorate(_classThis, null, _serverBuildInfo_decorators, { kind: "method", name: "serverBuildInfo", static: false, private: false, access: { has: obj => "serverBuildInfo" in obj, get: obj => obj.serverBuildInfo }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1243
|
+
__esDecorate(_classThis, null, _serverStatus_decorators, { kind: "method", name: "serverStatus", static: false, private: false, access: { has: obj => "serverStatus" in obj, get: obj => obj.serverStatus }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1244
|
+
__esDecorate(_classThis, null, _stats_decorators, { kind: "method", name: "stats", static: false, private: false, access: { has: obj => "stats" in obj, get: obj => obj.stats }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1245
|
+
__esDecorate(_classThis, null, _hostInfo_decorators, { kind: "method", name: "hostInfo", static: false, private: false, access: { has: obj => "hostInfo" in obj, get: obj => obj.hostInfo }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1246
|
+
__esDecorate(_classThis, null, _serverCmdLineOpts_decorators, { kind: "method", name: "serverCmdLineOpts", static: false, private: false, access: { has: obj => "serverCmdLineOpts" in obj, get: obj => obj.serverCmdLineOpts }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1247
|
+
__esDecorate(_classThis, null, _rotateCertificates_decorators, { kind: "method", name: "rotateCertificates", static: false, private: false, access: { has: obj => "rotateCertificates" in obj, get: obj => obj.rotateCertificates }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1248
|
+
__esDecorate(_classThis, null, _printCollectionStats_decorators, { kind: "method", name: "printCollectionStats", static: false, private: false, access: { has: obj => "printCollectionStats" in obj, get: obj => obj.printCollectionStats }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1249
|
+
__esDecorate(_classThis, null, _getProfilingStatus_decorators, { kind: "method", name: "getProfilingStatus", static: false, private: false, access: { has: obj => "getProfilingStatus" in obj, get: obj => obj.getProfilingStatus }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1250
|
+
__esDecorate(_classThis, null, _setProfilingLevel_decorators, { kind: "method", name: "setProfilingLevel", static: false, private: false, access: { has: obj => "setProfilingLevel" in obj, get: obj => obj.setProfilingLevel }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1251
|
+
__esDecorate(_classThis, null, _setLogLevel_decorators, { kind: "method", name: "setLogLevel", static: false, private: false, access: { has: obj => "setLogLevel" in obj, get: obj => obj.setLogLevel }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1252
|
+
__esDecorate(_classThis, null, _getLogComponents_decorators, { kind: "method", name: "getLogComponents", static: false, private: false, access: { has: obj => "getLogComponents" in obj, get: obj => obj.getLogComponents }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1253
|
+
__esDecorate(_classThis, null, _cloneDatabase_decorators, { kind: "method", name: "cloneDatabase", static: false, private: false, access: { has: obj => "cloneDatabase" in obj, get: obj => obj.cloneDatabase }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1254
|
+
__esDecorate(_classThis, null, _cloneCollection_decorators, { kind: "method", name: "cloneCollection", static: false, private: false, access: { has: obj => "cloneCollection" in obj, get: obj => obj.cloneCollection }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1255
|
+
__esDecorate(_classThis, null, _copyDatabase_decorators, { kind: "method", name: "copyDatabase", static: false, private: false, access: { has: obj => "copyDatabase" in obj, get: obj => obj.copyDatabase }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1256
|
+
__esDecorate(_classThis, null, _commandHelp_decorators, { kind: "method", name: "commandHelp", static: false, private: false, access: { has: obj => "commandHelp" in obj, get: obj => obj.commandHelp }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1257
|
+
__esDecorate(_classThis, null, _listCommands_decorators, { kind: "method", name: "listCommands", static: false, private: false, access: { has: obj => "listCommands" in obj, get: obj => obj.listCommands }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1258
|
+
__esDecorate(_classThis, null, _getLastErrorObj_decorators, { kind: "method", name: "getLastErrorObj", static: false, private: false, access: { has: obj => "getLastErrorObj" in obj, get: obj => obj.getLastErrorObj }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1259
|
+
__esDecorate(_classThis, null, _getLastError_decorators, { kind: "method", name: "getLastError", static: false, private: false, access: { has: obj => "getLastError" in obj, get: obj => obj.getLastError }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1260
|
+
__esDecorate(_classThis, null, _printShardingStatus_decorators, { kind: "method", name: "printShardingStatus", static: false, private: false, access: { has: obj => "printShardingStatus" in obj, get: obj => obj.printShardingStatus }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1261
|
+
__esDecorate(_classThis, null, _printSecondaryReplicationInfo_decorators, { kind: "method", name: "printSecondaryReplicationInfo", static: false, private: false, access: { has: obj => "printSecondaryReplicationInfo" in obj, get: obj => obj.printSecondaryReplicationInfo }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1262
|
+
__esDecorate(_classThis, null, _getReplicationInfo_decorators, { kind: "method", name: "getReplicationInfo", static: false, private: false, access: { has: obj => "getReplicationInfo" in obj, get: obj => obj.getReplicationInfo }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1263
|
+
__esDecorate(_classThis, null, _printReplicationInfo_decorators, { kind: "method", name: "printReplicationInfo", static: false, private: false, access: { has: obj => "printReplicationInfo" in obj, get: obj => obj.printReplicationInfo }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1264
|
+
__esDecorate(_classThis, null, _printSlaveReplicationInfo_decorators, { kind: "method", name: "printSlaveReplicationInfo", static: false, private: false, access: { has: obj => "printSlaveReplicationInfo" in obj, get: obj => obj.printSlaveReplicationInfo }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1265
|
+
__esDecorate(_classThis, null, _setSecondaryOk_decorators, { kind: "method", name: "setSecondaryOk", static: false, private: false, access: { has: obj => "setSecondaryOk" in obj, get: obj => obj.setSecondaryOk }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1266
|
+
__esDecorate(_classThis, null, _watch_decorators, { kind: "method", name: "watch", static: false, private: false, access: { has: obj => "watch" in obj, get: obj => obj.watch }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1267
|
+
__esDecorate(_classThis, null, _sql_decorators, { kind: "method", name: "sql", static: false, private: false, access: { has: obj => "sql" in obj, get: obj => obj.sql }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1268
|
+
__esDecorate(_classThis, null, _checkMetadataConsistency_decorators, { kind: "method", name: "checkMetadataConsistency", static: false, private: false, access: { has: obj => "checkMetadataConsistency" in obj, get: obj => obj.checkMetadataConsistency }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1269
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
1270
|
+
Database = _classThis = _classDescriptor.value;
|
|
1271
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
1272
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
1273
|
+
})();
|
|
1274
|
+
return Database = _classThis;
|
|
1275
|
+
})();
|
|
1293
1276
|
exports.default = Database;
|
|
1294
1277
|
//# sourceMappingURL=database.js.map
|