@zilliz/milvus2-sdk-node 2.2.10 → 2.2.12
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/README.md +3 -3
- package/dist/milvus/MilvusClient.d.ts +0 -4
- package/dist/milvus/MilvusClient.js +20 -48
- package/dist/milvus/MilvusClient.js.map +1 -1
- package/dist/milvus/OrmClient.d.ts +19 -0
- package/dist/milvus/OrmClient.js +77 -0
- package/dist/milvus/OrmClient.js.map +1 -0
- package/dist/milvus/const/ErrorReason.d.ts +36 -31
- package/dist/milvus/const/ErrorReason.js +39 -32
- package/dist/milvus/const/ErrorReason.js.map +1 -1
- package/dist/milvus/const/Milvus.d.ts +2 -9
- package/dist/milvus/const/Milvus.js +16 -33
- package/dist/milvus/const/Milvus.js.map +1 -1
- package/dist/milvus/const/client.d.ts +5 -0
- package/dist/milvus/const/client.js +10 -0
- package/dist/milvus/const/client.js.map +1 -0
- package/dist/milvus/const/defaults.d.ts +11 -0
- package/dist/milvus/const/defaults.js +16 -0
- package/dist/milvus/const/defaults.js.map +1 -0
- package/dist/milvus/const/highLevel.d.ts +23 -0
- package/dist/milvus/const/highLevel.js +26 -0
- package/dist/milvus/const/highLevel.js.map +1 -0
- package/dist/milvus/const/index.d.ts +4 -1
- package/dist/milvus/const/index.js +4 -1
- package/dist/milvus/const/index.js.map +1 -1
- package/dist/milvus/const/limits.d.ts +2 -0
- package/dist/milvus/const/limits.js +7 -0
- package/dist/milvus/const/limits.js.map +1 -0
- package/dist/milvus/grpc/BaseClient.d.ts +16 -7
- package/dist/milvus/grpc/BaseClient.js +37 -18
- package/dist/milvus/grpc/BaseClient.js.map +1 -1
- package/dist/milvus/grpc/Collection.d.ts +32 -3
- package/dist/milvus/grpc/Collection.js +242 -416
- package/dist/milvus/grpc/Collection.js.map +1 -1
- package/dist/milvus/grpc/Data.d.ts +68 -8
- package/dist/milvus/grpc/Data.js +539 -566
- package/dist/milvus/grpc/Data.js.map +1 -1
- package/dist/milvus/grpc/Database.d.ts +69 -0
- package/dist/milvus/grpc/Database.js +98 -0
- package/dist/milvus/grpc/Database.js.map +1 -0
- package/dist/milvus/grpc/GrpcClient.d.ts +18 -8
- package/dist/milvus/grpc/GrpcClient.js +87 -156
- package/dist/milvus/grpc/GrpcClient.js.map +1 -1
- package/dist/milvus/grpc/MilvusIndex.d.ts +1 -1
- package/dist/milvus/grpc/MilvusIndex.js +46 -142
- package/dist/milvus/grpc/MilvusIndex.js.map +1 -1
- package/dist/milvus/grpc/Partition.d.ts +1 -1
- package/dist/milvus/grpc/Partition.js +53 -157
- package/dist/milvus/grpc/Partition.js.map +1 -1
- package/dist/milvus/grpc/Resource.d.ts +2 -2
- package/dist/milvus/grpc/Resource.js +64 -170
- package/dist/milvus/grpc/Resource.js.map +1 -1
- package/dist/milvus/grpc/User.d.ts +1 -1
- package/dist/milvus/grpc/User.js +193 -381
- package/dist/milvus/grpc/User.js.map +1 -1
- package/dist/milvus/index.d.ts +1 -1
- package/dist/milvus/index.js +1 -1
- package/dist/milvus/index.js.map +1 -1
- package/dist/milvus/orm/Collection.d.ts +45 -0
- package/dist/milvus/orm/Collection.js +172 -0
- package/dist/milvus/orm/Collection.js.map +1 -0
- package/dist/milvus/orm/index.d.ts +2 -0
- package/dist/milvus/{types.js → orm/index.js} +3 -11
- package/dist/milvus/orm/index.js.map +1 -0
- package/dist/milvus/orm/utils.d.ts +27 -0
- package/dist/milvus/orm/utils.js +27 -0
- package/dist/milvus/orm/utils.js.map +1 -0
- package/dist/milvus/types/Client.d.ts +12 -1
- package/dist/milvus/types/Collection.d.ts +18 -4
- package/dist/milvus/types/Data.d.ts +41 -5
- package/dist/milvus/types/Database.d.ts +12 -0
- package/dist/milvus/types/Database.js +3 -0
- package/dist/milvus/types/Database.js.map +1 -0
- package/dist/milvus/types/HighLevel.d.ts +13 -0
- package/dist/milvus/types/HighLevel.js +3 -0
- package/dist/milvus/types/HighLevel.js.map +1 -0
- package/dist/milvus/types/MilvusIndex.d.ts +1 -1
- package/dist/milvus/types/Resource.d.ts +1 -1
- package/dist/milvus/types/{Index.d.ts → index.d.ts} +2 -0
- package/dist/milvus/types/{Index.js → index.js} +3 -1
- package/dist/milvus/types/index.js.map +1 -0
- package/dist/{utils → milvus/utils}/Blob.js +4 -4
- package/dist/milvus/utils/Blob.js.map +1 -0
- package/dist/{utils → milvus/utils}/Format.d.ts +66 -2
- package/dist/milvus/utils/Format.js +416 -0
- package/dist/milvus/utils/Format.js.map +1 -0
- package/dist/{utils → milvus/utils}/Function.d.ts +1 -1
- package/dist/{utils → milvus/utils}/Function.js +7 -7
- package/dist/milvus/utils/Function.js.map +1 -0
- package/dist/{utils → milvus/utils}/Grpc.d.ts +9 -8
- package/dist/milvus/utils/Grpc.js +190 -0
- package/dist/milvus/utils/Grpc.js.map +1 -0
- package/dist/{utils → milvus/utils}/Validate.d.ts +7 -1
- package/dist/milvus/utils/Validate.js +140 -0
- package/dist/milvus/utils/Validate.js.map +1 -0
- package/dist/{utils → milvus/utils}/index.d.ts +2 -0
- package/dist/{utils → milvus/utils}/index.js +2 -0
- package/dist/milvus/utils/index.js.map +1 -0
- package/dist/milvus/utils/logger.d.ts +1 -0
- package/dist/milvus/utils/logger.js +18 -0
- package/dist/milvus/utils/logger.js.map +1 -0
- package/dist/proto/proto/common.proto +38 -14
- package/dist/proto/proto/google/protobuf/descriptor.proto +8 -4
- package/dist/proto/proto/milvus.proto +86 -83
- package/dist/proto/proto/schema.proto +5 -0
- package/dist/sdk.json +1 -1
- package/package.json +14 -11
- package/dist/milvus/types/Index.js.map +0 -1
- package/dist/milvus/types.d.ts +0 -9
- package/dist/milvus/types.js.map +0 -1
- package/dist/proto/proto/feder.proto +0 -40
- package/dist/proto/proto/msg.proto +0 -107
- package/dist/utils/Blob.js.map +0 -1
- package/dist/utils/Format.js +0 -252
- package/dist/utils/Format.js.map +0 -1
- package/dist/utils/Function.js.map +0 -1
- package/dist/utils/Grpc.js +0 -170
- package/dist/utils/Grpc.js.map +0 -1
- package/dist/utils/Validate.js +0 -125
- package/dist/utils/Validate.js.map +0 -1
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/test.d.ts +0 -29
- package/dist/utils/test.js +0 -112
- package/dist/utils/test.js.map +0 -1
- /package/dist/{utils → milvus/utils}/Blob.d.ts +0 -0
|
@@ -1,30 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __assign = (this && this.__assign) || function () {
|
|
18
|
-
__assign = Object.assign || function(t) {
|
|
19
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
-
s = arguments[i];
|
|
21
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
-
t[p] = s[p];
|
|
23
|
-
}
|
|
24
|
-
return t;
|
|
25
|
-
};
|
|
26
|
-
return __assign.apply(this, arguments);
|
|
27
|
-
};
|
|
28
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
29
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
30
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -34,57 +8,22 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
34
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
35
9
|
});
|
|
36
10
|
};
|
|
37
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
38
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
39
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
40
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
41
|
-
function step(op) {
|
|
42
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
43
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
44
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
45
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
46
|
-
switch (op[0]) {
|
|
47
|
-
case 0: case 1: t = op; break;
|
|
48
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
49
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
50
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
51
|
-
default:
|
|
52
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
53
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
54
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
55
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
56
|
-
if (t[2]) _.ops.pop();
|
|
57
|
-
_.trys.pop(); continue;
|
|
58
|
-
}
|
|
59
|
-
op = body.call(thisArg, _);
|
|
60
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
61
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
65
|
-
var t = {};
|
|
66
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
67
|
-
t[p] = s[p];
|
|
68
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
69
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
70
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
71
|
-
t[p[i]] = s[p[i]];
|
|
72
|
-
}
|
|
73
|
-
return t;
|
|
74
|
-
};
|
|
75
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
76
12
|
exports.Collection = void 0;
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
var __1 = require("..");
|
|
80
|
-
var utils_2 = require("../../utils");
|
|
13
|
+
const Database_1 = require("./Database");
|
|
14
|
+
const __1 = require("../");
|
|
81
15
|
/**
|
|
82
16
|
* @see [collection operation examples](https://github.com/milvus-io/milvus-sdk-node/blob/main/example/Collection.ts)
|
|
83
17
|
*/
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
18
|
+
class Collection extends Database_1.Database {
|
|
19
|
+
constructor() {
|
|
20
|
+
super(...arguments);
|
|
21
|
+
// alias
|
|
22
|
+
this.list_collections = this.showCollections;
|
|
23
|
+
// alias
|
|
24
|
+
this.drop_collection = this.dropCollection;
|
|
25
|
+
// alias
|
|
26
|
+
this.listCollections = this.showCollections;
|
|
88
27
|
}
|
|
89
28
|
/**
|
|
90
29
|
* Create a collection in Milvus.
|
|
@@ -94,6 +33,7 @@ var Collection = /** @class */ (function (_super) {
|
|
|
94
33
|
* | :-- | :-- | :-- |
|
|
95
34
|
* | collection_name | String | Collection name |
|
|
96
35
|
* | description | String | Collection description |
|
|
36
|
+
* | num_partitions | number | number of partitions allowed |
|
|
97
37
|
* | consistency_level | String | "Strong"(Milvus default) | "Session" | "Bounded"| "Eventually" | "Customized"; |
|
|
98
38
|
* | fields | <a href="https://github.com/milvus-io/milvus-sdk-node/blob/main/milvus/types/Collection.ts#L8" target="_blank">FieldType</a> | Field data |
|
|
99
39
|
* | timeout? | number | An optional duration of time in millisecond to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined |
|
|
@@ -129,43 +69,39 @@ var Collection = /** @class */ (function (_super) {
|
|
|
129
69
|
* });
|
|
130
70
|
* ```
|
|
131
71
|
*/
|
|
132
|
-
|
|
72
|
+
createCollection(data) {
|
|
133
73
|
var _a;
|
|
134
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
// Return the promise.
|
|
164
|
-
return [2 /*return*/, promise];
|
|
165
|
-
}
|
|
166
|
-
});
|
|
74
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
// Destructure the data object and set default values for consistency_level and description.
|
|
76
|
+
const { fields, collection_name, consistency_level = 'Bounded', num_partitions, } = data || {};
|
|
77
|
+
// Check if fields and collection_name are present, otherwise throw an error.
|
|
78
|
+
if (!(fields === null || fields === void 0 ? void 0 : fields.length) || !collection_name) {
|
|
79
|
+
throw new Error(__1.ERROR_REASONS.CREATE_COLLECTION_CHECK_PARAMS);
|
|
80
|
+
}
|
|
81
|
+
// Check if the fields are valid.
|
|
82
|
+
(0, __1.checkCollectionFields)(fields);
|
|
83
|
+
// if num_partitions is set, validate it
|
|
84
|
+
if (typeof num_partitions !== 'undefined') {
|
|
85
|
+
(0, __1.validatePartitionNumbers)(num_partitions);
|
|
86
|
+
}
|
|
87
|
+
// Create the payload object with the collection_name, description, and fields.
|
|
88
|
+
// it should follow CollectionSchema in schema.proto
|
|
89
|
+
const payload = (0, __1.formatCollectionSchema)(data, this.fieldSchemaType);
|
|
90
|
+
// Create the collectionParams object from the payload.
|
|
91
|
+
const collectionParams = this.collectionSchemaType.create(payload);
|
|
92
|
+
// Encode the collectionParams object to bytes.
|
|
93
|
+
const schemaBytes = this.collectionSchemaType
|
|
94
|
+
.encode(collectionParams)
|
|
95
|
+
.finish();
|
|
96
|
+
// Get the consistency level value from the ConsistencyLevelEnum object.
|
|
97
|
+
const level = (_a = __1.ConsistencyLevelEnum[consistency_level]) !== null && _a !== void 0 ? _a : __1.ConsistencyLevelEnum.Bounded;
|
|
98
|
+
// Call the promisify function to create the collection.
|
|
99
|
+
const createPromise = yield (0, __1.promisify)(this.client, 'CreateCollection', Object.assign(Object.assign({}, data), { schema: schemaBytes, consistency_level: level }), data.timeout || this.timeout);
|
|
100
|
+
// load index
|
|
101
|
+
// Return the promise.
|
|
102
|
+
return createPromise;
|
|
167
103
|
});
|
|
168
|
-
}
|
|
104
|
+
}
|
|
169
105
|
/**
|
|
170
106
|
* Check if a collection exists.
|
|
171
107
|
*
|
|
@@ -190,21 +126,13 @@ var Collection = /** @class */ (function (_super) {
|
|
|
190
126
|
* });
|
|
191
127
|
* ```
|
|
192
128
|
*/
|
|
193
|
-
|
|
194
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
case 0:
|
|
199
|
-
(0, utils_1.checkCollectionName)(data);
|
|
200
|
-
return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'HasCollection', data, data.timeout || this.timeout)];
|
|
201
|
-
case 1:
|
|
202
|
-
promise = _a.sent();
|
|
203
|
-
return [2 /*return*/, promise];
|
|
204
|
-
}
|
|
205
|
-
});
|
|
129
|
+
hasCollection(data) {
|
|
130
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
131
|
+
(0, __1.checkCollectionName)(data);
|
|
132
|
+
const promise = yield (0, __1.promisify)(this.client, 'HasCollection', data, data.timeout || this.timeout);
|
|
133
|
+
return promise;
|
|
206
134
|
});
|
|
207
|
-
}
|
|
135
|
+
}
|
|
208
136
|
/**
|
|
209
137
|
* List all collections or get collection loading status.
|
|
210
138
|
*
|
|
@@ -229,32 +157,25 @@ var Collection = /** @class */ (function (_super) {
|
|
|
229
157
|
* new milvusClient(MILUVS_ADDRESS).showCollections();
|
|
230
158
|
* ```
|
|
231
159
|
*/
|
|
232
|
-
|
|
233
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
name: name,
|
|
247
|
-
id: promise.collection_ids[index],
|
|
248
|
-
timestamp: promise.created_utc_timestamps[index],
|
|
249
|
-
loadedPercentage: promise.inMemory_percentages[index],
|
|
250
|
-
});
|
|
251
|
-
});
|
|
252
|
-
promise.data = result;
|
|
253
|
-
return [2 /*return*/, promise];
|
|
254
|
-
}
|
|
160
|
+
showCollections(data) {
|
|
161
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
162
|
+
const promise = yield (0, __1.promisify)(this.client, 'ShowCollections', {
|
|
163
|
+
type: data ? data.type : __1.ShowCollectionsType.All,
|
|
164
|
+
collection_names: (data === null || data === void 0 ? void 0 : data.collection_names) || [],
|
|
165
|
+
}, (data === null || data === void 0 ? void 0 : data.timeout) || this.timeout);
|
|
166
|
+
const result = [];
|
|
167
|
+
promise.collection_names.forEach((name, index) => {
|
|
168
|
+
result.push({
|
|
169
|
+
name,
|
|
170
|
+
id: promise.collection_ids[index],
|
|
171
|
+
timestamp: promise.created_utc_timestamps[index],
|
|
172
|
+
loadedPercentage: promise.inMemory_percentages[index],
|
|
173
|
+
});
|
|
255
174
|
});
|
|
175
|
+
promise.data = result;
|
|
176
|
+
return promise;
|
|
256
177
|
});
|
|
257
|
-
}
|
|
178
|
+
}
|
|
258
179
|
/**
|
|
259
180
|
* Show the details of a collection, e.g. name, schema.
|
|
260
181
|
*
|
|
@@ -280,21 +201,13 @@ var Collection = /** @class */ (function (_super) {
|
|
|
280
201
|
* });
|
|
281
202
|
* ```
|
|
282
203
|
*/
|
|
283
|
-
|
|
284
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
case 0:
|
|
289
|
-
(0, utils_1.checkCollectionName)(data);
|
|
290
|
-
return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'DescribeCollection', data, data.timeout || this.timeout)];
|
|
291
|
-
case 1:
|
|
292
|
-
promise = _a.sent();
|
|
293
|
-
return [2 /*return*/, promise];
|
|
294
|
-
}
|
|
295
|
-
});
|
|
204
|
+
describeCollection(data) {
|
|
205
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
206
|
+
(0, __1.checkCollectionName)(data);
|
|
207
|
+
const promise = yield (0, __1.promisify)(this.client, 'DescribeCollection', data, data.timeout || this.timeout);
|
|
208
|
+
return (0, __1.formatDescribedCol)(promise);
|
|
296
209
|
});
|
|
297
|
-
}
|
|
210
|
+
}
|
|
298
211
|
/**
|
|
299
212
|
* Show the statistics information of a collection.
|
|
300
213
|
*
|
|
@@ -320,22 +233,14 @@ var Collection = /** @class */ (function (_super) {
|
|
|
320
233
|
* });
|
|
321
234
|
* ```
|
|
322
235
|
*/
|
|
323
|
-
|
|
324
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
(0, utils_1.checkCollectionName)(data);
|
|
330
|
-
return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'GetCollectionStatistics', data, data.timeout || this.timeout)];
|
|
331
|
-
case 1:
|
|
332
|
-
promise = _a.sent();
|
|
333
|
-
promise.data = (0, utils_1.formatKeyValueData)(promise.stats, ['row_count']);
|
|
334
|
-
return [2 /*return*/, promise];
|
|
335
|
-
}
|
|
336
|
-
});
|
|
236
|
+
getCollectionStatistics(data) {
|
|
237
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
238
|
+
(0, __1.checkCollectionName)(data);
|
|
239
|
+
const promise = yield (0, __1.promisify)(this.client, 'GetCollectionStatistics', data, data.timeout || this.timeout);
|
|
240
|
+
promise.data = (0, __1.formatKeyValueData)(promise.stats, ['row_count']);
|
|
241
|
+
return promise;
|
|
337
242
|
});
|
|
338
|
-
}
|
|
243
|
+
}
|
|
339
244
|
/**
|
|
340
245
|
* Load collection data into query nodes, then you can do vector search on this collection.
|
|
341
246
|
* It's async function, but we can use showCollections to check loading status.
|
|
@@ -362,21 +267,13 @@ var Collection = /** @class */ (function (_super) {
|
|
|
362
267
|
* });
|
|
363
268
|
* ```
|
|
364
269
|
*/
|
|
365
|
-
|
|
366
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
case 0:
|
|
371
|
-
(0, utils_1.checkCollectionName)(data);
|
|
372
|
-
return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'LoadCollection', data, data.timeout || this.timeout)];
|
|
373
|
-
case 1:
|
|
374
|
-
promise = _a.sent();
|
|
375
|
-
return [2 /*return*/, promise];
|
|
376
|
-
}
|
|
377
|
-
});
|
|
270
|
+
loadCollection(data) {
|
|
271
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
272
|
+
(0, __1.checkCollectionName)(data);
|
|
273
|
+
const promise = yield (0, __1.promisify)(this.client, 'LoadCollection', data, data.timeout || this.timeout);
|
|
274
|
+
return promise;
|
|
378
275
|
});
|
|
379
|
-
}
|
|
276
|
+
}
|
|
380
277
|
/**
|
|
381
278
|
* Same function with loadCollection, but it's sync function.
|
|
382
279
|
* Help to ensure this collection is loaded.
|
|
@@ -403,43 +300,28 @@ var Collection = /** @class */ (function (_super) {
|
|
|
403
300
|
* });
|
|
404
301
|
* ```
|
|
405
302
|
*/
|
|
406
|
-
|
|
407
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
_a.label = 2;
|
|
421
|
-
case 2:
|
|
422
|
-
if (!(Number(loadedPercentage) < 100)) return [3 /*break*/, 5];
|
|
423
|
-
return [4 /*yield*/, this.getLoadingProgress({
|
|
424
|
-
collection_name: data.collection_name,
|
|
425
|
-
})];
|
|
426
|
-
case 3:
|
|
427
|
-
res = _a.sent();
|
|
428
|
-
if (res.status.error_code !== __1.ErrorCode.SUCCESS) {
|
|
429
|
-
throw new Error("ErrorCode: ".concat(res.status.error_code, ". Reason: ").concat(res.status.reason));
|
|
430
|
-
}
|
|
431
|
-
loadedPercentage = Number(res.progress);
|
|
432
|
-
// sleep 400ms
|
|
433
|
-
return [4 /*yield*/, (0, utils_1.sleep)(400)];
|
|
434
|
-
case 4:
|
|
435
|
-
// sleep 400ms
|
|
436
|
-
_a.sent();
|
|
437
|
-
return [3 /*break*/, 2];
|
|
438
|
-
case 5: return [2 /*return*/, promise];
|
|
303
|
+
loadCollectionSync(data) {
|
|
304
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
305
|
+
(0, __1.checkCollectionName)(data);
|
|
306
|
+
const promise = yield (0, __1.promisify)(this.client, 'LoadCollection', data, data.timeout || this.timeout);
|
|
307
|
+
if (promise.error_code !== __1.ErrorCode.SUCCESS) {
|
|
308
|
+
throw new Error(`ErrorCode: ${promise.error_code}. Reason: ${promise.reason}`);
|
|
309
|
+
}
|
|
310
|
+
let loadedPercentage = 0;
|
|
311
|
+
while (Number(loadedPercentage) < 100) {
|
|
312
|
+
let res = yield this.getLoadingProgress({
|
|
313
|
+
collection_name: data.collection_name,
|
|
314
|
+
});
|
|
315
|
+
if (res.status.error_code !== __1.ErrorCode.SUCCESS) {
|
|
316
|
+
throw new Error(`ErrorCode: ${res.status.error_code}. Reason: ${res.status.reason}`);
|
|
439
317
|
}
|
|
440
|
-
|
|
318
|
+
loadedPercentage = Number(res.progress);
|
|
319
|
+
// sleep 400ms
|
|
320
|
+
yield (0, __1.sleep)(400);
|
|
321
|
+
}
|
|
322
|
+
return promise;
|
|
441
323
|
});
|
|
442
|
-
}
|
|
324
|
+
}
|
|
443
325
|
/**
|
|
444
326
|
* Release a collection from cache to reduce cache usage.
|
|
445
327
|
* Note that you cannot search while the corresponding collection is unloaded.
|
|
@@ -464,21 +346,13 @@ var Collection = /** @class */ (function (_super) {
|
|
|
464
346
|
* });
|
|
465
347
|
* ```
|
|
466
348
|
*/
|
|
467
|
-
|
|
468
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
case 0:
|
|
473
|
-
(0, utils_1.checkCollectionName)(data);
|
|
474
|
-
return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'ReleaseCollection', data, data.timeout || this.timeout)];
|
|
475
|
-
case 1:
|
|
476
|
-
promise = _a.sent();
|
|
477
|
-
return [2 /*return*/, promise];
|
|
478
|
-
}
|
|
479
|
-
});
|
|
349
|
+
releaseCollection(data) {
|
|
350
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
351
|
+
(0, __1.checkCollectionName)(data);
|
|
352
|
+
const promise = yield (0, __1.promisify)(this.client, 'ReleaseCollection', data, data.timeout || this.timeout);
|
|
353
|
+
return promise;
|
|
480
354
|
});
|
|
481
|
-
}
|
|
355
|
+
}
|
|
482
356
|
/**
|
|
483
357
|
* Rename a collection
|
|
484
358
|
*
|
|
@@ -504,22 +378,15 @@ var Collection = /** @class */ (function (_super) {
|
|
|
504
378
|
* });
|
|
505
379
|
* ```
|
|
506
380
|
*/
|
|
507
|
-
|
|
508
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
newName: data.new_collection_name,
|
|
515
|
-
}, data.timeout || this.timeout)];
|
|
516
|
-
case 1:
|
|
517
|
-
promise = _a.sent();
|
|
518
|
-
return [2 /*return*/, promise];
|
|
519
|
-
}
|
|
520
|
-
});
|
|
381
|
+
renameCollection(data) {
|
|
382
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
383
|
+
const promise = yield (0, __1.promisify)(this.client, 'RenameCollection', {
|
|
384
|
+
oldName: data.collection_name,
|
|
385
|
+
newName: data.new_collection_name,
|
|
386
|
+
}, data.timeout || this.timeout);
|
|
387
|
+
return promise;
|
|
521
388
|
});
|
|
522
|
-
}
|
|
389
|
+
}
|
|
523
390
|
/**
|
|
524
391
|
* Drop a collection. Note that this drops all data in the collection.
|
|
525
392
|
*
|
|
@@ -543,21 +410,13 @@ var Collection = /** @class */ (function (_super) {
|
|
|
543
410
|
* });
|
|
544
411
|
* ```
|
|
545
412
|
*/
|
|
546
|
-
|
|
547
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
case 0:
|
|
552
|
-
(0, utils_1.checkCollectionName)(data);
|
|
553
|
-
return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'DropCollection', data, data.timeout || this.timeout)];
|
|
554
|
-
case 1:
|
|
555
|
-
promise = _a.sent();
|
|
556
|
-
return [2 /*return*/, promise];
|
|
557
|
-
}
|
|
558
|
-
});
|
|
413
|
+
dropCollection(data) {
|
|
414
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
415
|
+
(0, __1.checkCollectionName)(data);
|
|
416
|
+
const promise = yield (0, __1.promisify)(this.client, 'DropCollection', data, data.timeout || this.timeout);
|
|
417
|
+
return promise;
|
|
559
418
|
});
|
|
560
|
-
}
|
|
419
|
+
}
|
|
561
420
|
/**
|
|
562
421
|
* Create collection alias, then you can use alias instead of collection_name when you do vector search
|
|
563
422
|
*
|
|
@@ -584,24 +443,16 @@ var Collection = /** @class */ (function (_super) {
|
|
|
584
443
|
* });
|
|
585
444
|
* ```
|
|
586
445
|
*/
|
|
587
|
-
|
|
588
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
throw new Error(__1.ERROR_REASONS.ALIAS_NAME_IS_REQUIRED);
|
|
596
|
-
}
|
|
597
|
-
return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'CreateAlias', data, data.timeout || this.timeout)];
|
|
598
|
-
case 1:
|
|
599
|
-
promise = _a.sent();
|
|
600
|
-
return [2 /*return*/, promise];
|
|
601
|
-
}
|
|
602
|
-
});
|
|
446
|
+
createAlias(data) {
|
|
447
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
448
|
+
(0, __1.checkCollectionName)(data);
|
|
449
|
+
if (!data.alias) {
|
|
450
|
+
throw new Error(__1.ERROR_REASONS.ALIAS_NAME_IS_REQUIRED);
|
|
451
|
+
}
|
|
452
|
+
const promise = yield (0, __1.promisify)(this.client, 'CreateAlias', data, data.timeout || this.timeout);
|
|
453
|
+
return promise;
|
|
603
454
|
});
|
|
604
|
-
}
|
|
455
|
+
}
|
|
605
456
|
/**
|
|
606
457
|
* Drop a collection alias
|
|
607
458
|
*
|
|
@@ -628,23 +479,15 @@ var Collection = /** @class */ (function (_super) {
|
|
|
628
479
|
* });
|
|
629
480
|
* ```
|
|
630
481
|
*/
|
|
631
|
-
|
|
632
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
throw new Error(__1.ERROR_REASONS.ALIAS_NAME_IS_REQUIRED);
|
|
639
|
-
}
|
|
640
|
-
return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'DropAlias', data, data.timeout || this.timeout)];
|
|
641
|
-
case 1:
|
|
642
|
-
promise = _a.sent();
|
|
643
|
-
return [2 /*return*/, promise];
|
|
644
|
-
}
|
|
645
|
-
});
|
|
482
|
+
dropAlias(data) {
|
|
483
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
484
|
+
if (!data.alias) {
|
|
485
|
+
throw new Error(__1.ERROR_REASONS.ALIAS_NAME_IS_REQUIRED);
|
|
486
|
+
}
|
|
487
|
+
const promise = yield (0, __1.promisify)(this.client, 'DropAlias', data, data.timeout || this.timeout);
|
|
488
|
+
return promise;
|
|
646
489
|
});
|
|
647
|
-
}
|
|
490
|
+
}
|
|
648
491
|
/**
|
|
649
492
|
* alter a collection alias
|
|
650
493
|
*
|
|
@@ -671,24 +514,16 @@ var Collection = /** @class */ (function (_super) {
|
|
|
671
514
|
* });
|
|
672
515
|
* ```
|
|
673
516
|
*/
|
|
674
|
-
|
|
675
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
throw new Error(__1.ERROR_REASONS.ALIAS_NAME_IS_REQUIRED);
|
|
683
|
-
}
|
|
684
|
-
return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'AlterAlias', data, data.timeout || this.timeout)];
|
|
685
|
-
case 1:
|
|
686
|
-
promise = _a.sent();
|
|
687
|
-
return [2 /*return*/, promise];
|
|
688
|
-
}
|
|
689
|
-
});
|
|
517
|
+
alterAlias(data) {
|
|
518
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
519
|
+
(0, __1.checkCollectionName)(data);
|
|
520
|
+
if (!data.alias) {
|
|
521
|
+
throw new Error(__1.ERROR_REASONS.ALIAS_NAME_IS_REQUIRED);
|
|
522
|
+
}
|
|
523
|
+
const promise = yield (0, __1.promisify)(this.client, 'AlterAlias', data, data.timeout || this.timeout);
|
|
524
|
+
return promise;
|
|
690
525
|
});
|
|
691
|
-
}
|
|
526
|
+
}
|
|
692
527
|
/**
|
|
693
528
|
* Do compaction for the collection.
|
|
694
529
|
*
|
|
@@ -712,26 +547,16 @@ var Collection = /** @class */ (function (_super) {
|
|
|
712
547
|
* });
|
|
713
548
|
* ```
|
|
714
549
|
*/
|
|
715
|
-
|
|
716
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
case 1:
|
|
724
|
-
collectionInfo = _a.sent();
|
|
725
|
-
return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'ManualCompaction', {
|
|
726
|
-
collectionID: collectionInfo.collectionID,
|
|
727
|
-
}, data.timeout || this.timeout)];
|
|
728
|
-
case 2:
|
|
729
|
-
res = _a.sent();
|
|
730
|
-
return [2 /*return*/, res];
|
|
731
|
-
}
|
|
732
|
-
});
|
|
550
|
+
compact(data) {
|
|
551
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
552
|
+
(0, __1.checkCollectionName)(data);
|
|
553
|
+
const collectionInfo = yield this.describeCollection(data);
|
|
554
|
+
const res = yield (0, __1.promisify)(this.client, 'ManualCompaction', {
|
|
555
|
+
collectionID: collectionInfo.collectionID,
|
|
556
|
+
}, data.timeout || this.timeout);
|
|
557
|
+
return res;
|
|
733
558
|
});
|
|
734
|
-
}
|
|
559
|
+
}
|
|
735
560
|
/**
|
|
736
561
|
* Get compaction states of a targeted compaction id
|
|
737
562
|
*
|
|
@@ -755,23 +580,15 @@ var Collection = /** @class */ (function (_super) {
|
|
|
755
580
|
* });
|
|
756
581
|
* ```
|
|
757
582
|
*/
|
|
758
|
-
|
|
759
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
throw new Error(__1.ERROR_REASONS.COMPACTIONID_IS_REQUIRED);
|
|
766
|
-
}
|
|
767
|
-
return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'GetCompactionState', data, data.timeout || this.timeout)];
|
|
768
|
-
case 1:
|
|
769
|
-
res = _a.sent();
|
|
770
|
-
return [2 /*return*/, res];
|
|
771
|
-
}
|
|
772
|
-
});
|
|
583
|
+
getCompactionState(data) {
|
|
584
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
585
|
+
if (!data || !data.compactionID) {
|
|
586
|
+
throw new Error(__1.ERROR_REASONS.COMPACTION_ID_IS_REQUIRED);
|
|
587
|
+
}
|
|
588
|
+
const res = yield (0, __1.promisify)(this.client, 'GetCompactionState', data, data.timeout || this.timeout);
|
|
589
|
+
return res;
|
|
773
590
|
});
|
|
774
|
-
}
|
|
591
|
+
}
|
|
775
592
|
/**
|
|
776
593
|
* Get compaction states of a targeted compaction id
|
|
777
594
|
*
|
|
@@ -795,23 +612,15 @@ var Collection = /** @class */ (function (_super) {
|
|
|
795
612
|
* });
|
|
796
613
|
* ```
|
|
797
614
|
*/
|
|
798
|
-
|
|
799
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
throw new Error(__1.ERROR_REASONS.COMPACTIONID_IS_REQUIRED);
|
|
806
|
-
}
|
|
807
|
-
return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'GetCompactionStateWithPlans', data, data.timeout || this.timeout)];
|
|
808
|
-
case 1:
|
|
809
|
-
res = _a.sent();
|
|
810
|
-
return [2 /*return*/, res];
|
|
811
|
-
}
|
|
812
|
-
});
|
|
615
|
+
getCompactionStateWithPlans(data) {
|
|
616
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
617
|
+
if (!data || !data.compactionID) {
|
|
618
|
+
throw new Error(__1.ERROR_REASONS.COMPACTION_ID_IS_REQUIRED);
|
|
619
|
+
}
|
|
620
|
+
const res = yield (0, __1.promisify)(this.client, 'GetCompactionStateWithPlans', data, data.timeout || this.timeout);
|
|
621
|
+
return res;
|
|
813
622
|
});
|
|
814
|
-
}
|
|
623
|
+
}
|
|
815
624
|
/**
|
|
816
625
|
* Get replicas
|
|
817
626
|
*
|
|
@@ -852,23 +661,15 @@ var Collection = /** @class */ (function (_super) {
|
|
|
852
661
|
* }
|
|
853
662
|
* ```
|
|
854
663
|
*/
|
|
855
|
-
|
|
856
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
throw new Error(__1.ERROR_REASONS.COLLECTION_ID_IS_REQUIRED);
|
|
863
|
-
}
|
|
864
|
-
return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'GetReplicas', data, data.timeout || this.timeout)];
|
|
865
|
-
case 1:
|
|
866
|
-
res = _a.sent();
|
|
867
|
-
return [2 /*return*/, res];
|
|
868
|
-
}
|
|
869
|
-
});
|
|
664
|
+
getReplicas(data) {
|
|
665
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
666
|
+
if (!data || !data.collectionID) {
|
|
667
|
+
throw new Error(__1.ERROR_REASONS.COLLECTION_ID_IS_REQUIRED);
|
|
668
|
+
}
|
|
669
|
+
const res = yield (0, __1.promisify)(this.client, 'GetReplicas', data, data.timeout || this.timeout);
|
|
670
|
+
return res;
|
|
870
671
|
});
|
|
871
|
-
}
|
|
672
|
+
}
|
|
872
673
|
/**
|
|
873
674
|
* Get loading progress of a collection
|
|
874
675
|
*
|
|
@@ -895,23 +696,15 @@ var Collection = /** @class */ (function (_super) {
|
|
|
895
696
|
* });
|
|
896
697
|
* ```
|
|
897
698
|
*/
|
|
898
|
-
|
|
899
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
throw new Error(__1.ERROR_REASONS.COLLECTION_NAME_IS_REQUIRED);
|
|
906
|
-
}
|
|
907
|
-
return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'GetLoadingProgress', data, data.timeout || this.timeout)];
|
|
908
|
-
case 1:
|
|
909
|
-
res = _a.sent();
|
|
910
|
-
return [2 /*return*/, res];
|
|
911
|
-
}
|
|
912
|
-
});
|
|
699
|
+
getLoadingProgress(data) {
|
|
700
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
701
|
+
if (!data || !data.collection_name) {
|
|
702
|
+
throw new Error(__1.ERROR_REASONS.COLLECTION_NAME_IS_REQUIRED);
|
|
703
|
+
}
|
|
704
|
+
const res = yield (0, __1.promisify)(this.client, 'GetLoadingProgress', data, data.timeout || this.timeout);
|
|
705
|
+
return res;
|
|
913
706
|
});
|
|
914
|
-
}
|
|
707
|
+
}
|
|
915
708
|
/**
|
|
916
709
|
* Get the loading state of a collection
|
|
917
710
|
*
|
|
@@ -937,24 +730,57 @@ var Collection = /** @class */ (function (_super) {
|
|
|
937
730
|
* });
|
|
938
731
|
* ```
|
|
939
732
|
*/
|
|
940
|
-
|
|
941
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
733
|
+
getLoadState(data) {
|
|
734
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
735
|
+
if (!data || !data.collection_name) {
|
|
736
|
+
throw new Error(__1.ERROR_REASONS.COLLECTION_NAME_IS_REQUIRED);
|
|
737
|
+
}
|
|
738
|
+
const res = yield (0, __1.promisify)(this.client, 'GetLoadState', data, data.timeout || this.timeout);
|
|
739
|
+
return res;
|
|
740
|
+
});
|
|
741
|
+
}
|
|
742
|
+
/**
|
|
743
|
+
* Get the primary key field name
|
|
744
|
+
*
|
|
745
|
+
* @param data
|
|
746
|
+
* | Property | Type | Description |
|
|
747
|
+
* | :-- | :-- | :-- |
|
|
748
|
+
* | collection_name | string | the name of the collection |
|
|
749
|
+
* | timeout? | number | An optional duration of time in milliseconds to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or an error occurs. Default is undefined |
|
|
750
|
+
*
|
|
751
|
+
* @returns
|
|
752
|
+
* | Property | Description |
|
|
753
|
+
* | :-- | :-- |
|
|
754
|
+
* | pkfield | the primary key field name |
|
|
755
|
+
*
|
|
756
|
+
* @throws {Error} if `collection_name` property is not present in `data`
|
|
757
|
+
*
|
|
758
|
+
* #### Example
|
|
759
|
+
*
|
|
760
|
+
* ```
|
|
761
|
+
* new milvusClient(MILUVS_ADDRESS).getPkFieldName({
|
|
762
|
+
* collection_name: 'my_collection',
|
|
763
|
+
* });
|
|
764
|
+
* ```
|
|
765
|
+
*/
|
|
766
|
+
getPkFieldName(data) {
|
|
767
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
768
|
+
// get collection info
|
|
769
|
+
const collectionInfo = yield this.describeCollection(data);
|
|
770
|
+
// pk field
|
|
771
|
+
let pkField = '';
|
|
772
|
+
// extract key information
|
|
773
|
+
for (let i = 0; i < collectionInfo.schema.fields.length; i++) {
|
|
774
|
+
const f = collectionInfo.schema.fields[i];
|
|
775
|
+
// get pk field info
|
|
776
|
+
if (f.is_primary_key) {
|
|
777
|
+
pkField = f.name;
|
|
778
|
+
break;
|
|
953
779
|
}
|
|
954
|
-
}
|
|
780
|
+
}
|
|
781
|
+
return pkField;
|
|
955
782
|
});
|
|
956
|
-
}
|
|
957
|
-
|
|
958
|
-
}(BaseClient_1.BaseClient));
|
|
783
|
+
}
|
|
784
|
+
}
|
|
959
785
|
exports.Collection = Collection;
|
|
960
786
|
//# sourceMappingURL=Collection.js.map
|