Browse Source

fix type

Signed-off-by: shanghaikid <jiangruiyi@gmail.com>
shanghaikid 1 year ago
parent
commit
269343529a

+ 1 - 1
client/src/http/BaseModel.ts

@@ -50,7 +50,7 @@ export default class BaseModel {
     } as any;
     } as any;
     if (timeout) httpConfig.timeout = timeout;
     if (timeout) httpConfig.timeout = timeout;
     const res = await http(httpConfig);
     const res = await http(httpConfig);
-    return res.data.data;
+    return new this(res.data.data || {});
   }
   }
 
 
   /**
   /**

+ 1 - 1
client/src/http/Collection.ts

@@ -55,7 +55,7 @@ export class CollectionHttp extends BaseModel implements CollectionView {
     return super.search({
     return super.search({
       path: `${this.COLLECTIONS_URL}/${name}`,
       path: `${this.COLLECTIONS_URL}/${name}`,
       params: {},
       params: {},
-    });
+    }) as Promise<CollectionHttp>;
   }
   }
 
 
   static createCollection(data: any) {
   static createCollection(data: any) {

+ 1 - 0
client/src/i18n/en/collection.ts

@@ -65,6 +65,7 @@ const collectionTrans = {
   partitionKey: 'Partition Key',
   partitionKey: 'Partition Key',
   partitionKeyTooltip:
   partitionKeyTooltip:
     ' Milvus will store entities in a partition according to the values in the partition key field. Only one Int64 or VarChar field is supported.',
     ' Milvus will store entities in a partition according to the values in the partition key field. Only one Int64 or VarChar field is supported.',
+  enableDynamicSchema: 'Enable Dynamic Schema',
 
 
   // load dialog
   // load dialog
   loadTitle: 'Load Collection',
   loadTitle: 'Load Collection',

+ 1 - 1
client/src/pages/dialogs/CreateCollectionDialog.tsx

@@ -284,7 +284,7 @@ const CreateCollectionDialog: FC<CollectionCreateProps> = ({ onCreate }) => {
             checked={form.enableDynamicField}
             checked={form.enableDynamicField}
             control={<Checkbox />}
             control={<Checkbox />}
             onChange={changeEnableDynamicField}
             onChange={changeEnableDynamicField}
-            label="Enable Dynamic Fields"
+            label={collectionTrans('enableDynamicSchema')}
           />
           />
         </fieldset>
         </fieldset>
 
 

+ 2 - 4
client/src/pages/preview/Preview.tsx

@@ -44,11 +44,9 @@ const Preview: FC<{
 
 
   const loadData = async (collectionName: string) => {
   const loadData = async (collectionName: string) => {
     // get schema list
     // get schema list
-    const collection = new CollectionHttp(
-      await CollectionHttp.getCollection(collectionName)
-    );
+    const collection = await CollectionHttp.getCollection(collectionName);
 
 
-    const schemaList = collection._fields;
+    const schemaList = collection._fields!;
     let nameList = schemaList.map(v => ({
     let nameList = schemaList.map(v => ({
       name: v.name,
       name: v.name,
       type: v.data_type,
       type: v.data_type,

+ 1 - 3
client/src/pages/query/Query.tsx

@@ -69,9 +69,7 @@ const Query: FC<{
   };
   };
 
 
   const getFields = async (collectionName: string) => {
   const getFields = async (collectionName: string) => {
-    const collection = new CollectionHttp(
-      await CollectionHttp.getCollection(collectionName)
-    );
+    const collection = await CollectionHttp.getCollection(collectionName);
     const schemaList = collection._fields;
     const schemaList = collection._fields;
 
 
     const nameList = schemaList.map(v => ({
     const nameList = schemaList.map(v => ({