@ejfdelgado/ejflab-back 1.20.1 → 1.20.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/srv/MilvusSrv.mjs +35 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ejfdelgado/ejflab-back",
3
- "version": "1.20.1",
3
+ "version": "1.20.3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/ejfdelgado/ejflab-back.git"
@@ -18,7 +18,7 @@
18
18
  "license": "ISC",
19
19
  "private": false,
20
20
  "dependencies": {
21
- "@ejfdelgado/ejflab-common": "1.12.1",
21
+ "@ejfdelgado/ejflab-common": "1.12.3",
22
22
  "@google-cloud/compute": "^4.7.0",
23
23
  "@google-cloud/firestore": "^7.9.0",
24
24
  "@google-cloud/storage": "^7.11.3",
package/srv/MilvusSrv.mjs CHANGED
@@ -1,7 +1,9 @@
1
+ import fs from "fs";
1
2
  import { MilvusClient, DataType } from "@zilliz/milvus2-sdk-node";
2
3
  import { encode, decode } from "@msgpack/msgpack";
3
4
  import { General } from "./common/General.mjs";
4
5
  import { CommandMilvus } from "@ejfdelgado/ejflab-common/src/flowchart/steps/CommandMilvus.js";
6
+ import { SimpleObj } from "@ejfdelgado/ejflab-common/src/SimpleObj.js";
5
7
 
6
8
  export class MilvusSrv {
7
9
  // MilvusSrv.checkErrors(res);
@@ -64,7 +66,7 @@ export class MilvusSrv {
64
66
  for (let j = 0; j < data.length; j++) {
65
67
  const collection = data[j];
66
68
  console.log(` - Collection: ${collection.name}`);
67
- myDb.collections.push(collection.name);
69
+ myDb.collections.push({ name: collection.name });
68
70
  }
69
71
  }
70
72
  return response;
@@ -80,6 +82,21 @@ export class MilvusSrv {
80
82
  }
81
83
  }
82
84
  }
85
+
86
+ static async describeCollectionOfDatabase(client, db_name, collection_name) {
87
+ const resUseDatabase1 = await client.useDatabase({ db_name: db_name });
88
+ MilvusSrv.checkErrors(resUseDatabase1);
89
+ const description = await client.describeCollection({ collection_name: collection_name });
90
+ return description;
91
+ }
92
+
93
+ static async dropCollectionOfDatabase(client, db_name, collection_name) {
94
+ const resUseDatabase1 = await client.useDatabase({ db_name: db_name });
95
+ MilvusSrv.checkErrors(resUseDatabase1);
96
+ await MilvusSrv.dropCollection(client, collection_name);
97
+ return true;
98
+ }
99
+
83
100
  static async dropCollection(client, collection_name) {
84
101
  console.log(`Drop collection ${collection_name}...`);
85
102
  const resHasCollection = await client.hasCollection({ collection_name });
@@ -135,6 +152,7 @@ export class MilvusSrv {
135
152
  // Translate data types
136
153
  const myCopy = JSON.parse(JSON.stringify(myJson));
137
154
  const collection_name = myCopy.collection_name;
155
+ console.log(`createCollectionWithSchema... ${collection_name}`);
138
156
  const exists = await this.existsCollection(client, collection_name);
139
157
  if (exists) {
140
158
  if (recreate) {
@@ -159,6 +177,7 @@ export class MilvusSrv {
159
177
  database.create
160
178
  database.recreate
161
179
  collection.create
180
+ collection.destroy
162
181
  introspect
163
182
  database.destroy
164
183
  database.destroy_temp
@@ -172,7 +191,10 @@ export class MilvusSrv {
172
191
  return MilvusSrv;
173
192
  }
174
193
  };
175
- }
194
+ },
195
+ data: {
196
+ configuration: {}
197
+ },
176
198
  };
177
199
  const id = '';
178
200
  const commandName = 'milvus';
@@ -180,7 +202,17 @@ export class MilvusSrv {
180
202
  const command = new CommandMilvus(context, id, commandName, argsTxt);
181
203
  const action = General.readParam(req, "action", null);
182
204
  const db = General.readParam(req, "db", null);
183
- const collection = General.readParam(req, "collection", null);
205
+ let collection = General.readParam(req, "collection", null);
206
+ if (action == "collection.create") {
207
+ // Read configuration file...
208
+ const json = General.readParam(req, "json", null);
209
+ const jsonTxt = fs.readFileSync(json, { encoding: "utf8" });
210
+ const jsonParsed = JSON.parse(jsonTxt);
211
+ const path = General.readParam(req, "path", null);
212
+ const configuration = SimpleObj.getValue(jsonParsed, path, null);
213
+ context.data.configuration = configuration;
214
+ collection = "configuration";
215
+ }
184
216
  command.args = [action, db, collection];
185
217
  const answer = await command.computation();
186
218
  const response = {