@ejfdelgado/ejflab-back 1.20.0 → 1.20.1

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 +50 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ejfdelgado/ejflab-back",
3
- "version": "1.20.0",
3
+ "version": "1.20.1",
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.0",
21
+ "@ejfdelgado/ejflab-common": "1.12.1",
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,5 +1,7 @@
1
1
  import { MilvusClient, DataType } from "@zilliz/milvus2-sdk-node";
2
2
  import { encode, decode } from "@msgpack/msgpack";
3
+ import { General } from "./common/General.mjs";
4
+ import { CommandMilvus } from "@ejfdelgado/ejflab-common/src/flowchart/steps/CommandMilvus.js";
3
5
 
4
6
  export class MilvusSrv {
5
7
  // MilvusSrv.checkErrors(res);
@@ -27,6 +29,10 @@ export class MilvusSrv {
27
29
  client
28
30
  }
29
31
  }
32
+ static async releaseConnection(client) {
33
+ console.log("Milvus disconnect");
34
+ await client.closeConnection();
35
+ }
30
36
  static async existsDatabase(client, name) {
31
37
  const res = await client.listDatabases();
32
38
  return res.db_names.indexOf(name) >= 0;
@@ -41,9 +47,15 @@ export class MilvusSrv {
41
47
  const res = await client.listDatabases();
42
48
  MilvusSrv.checkErrors(res);
43
49
  const databases = res.db_names;
50
+ const response = { dbs: [] };
44
51
  for (let i = 0; i < databases.length; i++) {
45
52
  const database = databases[i];
46
53
  console.log(`- Database: ${database}`);
54
+ const myDb = {
55
+ name: database,
56
+ collections: []
57
+ };
58
+ response.dbs.push(myDb);
47
59
  const resUseDatabase = await client.useDatabase({ db_name: database });
48
60
  MilvusSrv.checkErrors(resUseDatabase);
49
61
  const resListCollections = await client.listCollections();
@@ -52,8 +64,10 @@ export class MilvusSrv {
52
64
  for (let j = 0; j < data.length; j++) {
53
65
  const collection = data[j];
54
66
  console.log(` - Collection: ${collection.name}`);
67
+ myDb.collections.push(collection.name);
55
68
  }
56
69
  }
70
+ return response;
57
71
  }
58
72
  static async dropDatabaseTemp(client) {
59
73
  const res = await client.listDatabases();
@@ -140,6 +154,42 @@ export class MilvusSrv {
140
154
  const res = await client.createCollection(myCopy);
141
155
  MilvusSrv.checkErrors(res);
142
156
  }
157
+ /*
158
+ action:
159
+ database.create
160
+ database.recreate
161
+ collection.create
162
+ introspect
163
+ database.destroy
164
+ database.destroy_temp
165
+ */
166
+ static async admin(req, res, next) {
167
+ //this.context.getSuperContext().getMilvusClient();
168
+ const context = {
169
+ getSuperContext: () => {
170
+ return {
171
+ getMilvusClient: () => {
172
+ return MilvusSrv;
173
+ }
174
+ };
175
+ }
176
+ };
177
+ const id = '';
178
+ const commandName = 'milvus';
179
+ const argsTxt = '';
180
+ const command = new CommandMilvus(context, id, commandName, argsTxt);
181
+ const action = General.readParam(req, "action", null);
182
+ const db = General.readParam(req, "db", null);
183
+ const collection = General.readParam(req, "collection", null);
184
+ command.args = [action, db, collection];
185
+ const answer = await command.computation();
186
+ const response = {
187
+ args: command.args,
188
+ answer: answer,
189
+ status: "ok",
190
+ };
191
+ res.status(200).send(response);
192
+ }
143
193
  static async ping(req, res, next) {
144
194
  const { client } = MilvusSrv.connect();
145
195
  const databases = await client.listDatabases();