diff --git a/milvus/grpc/Database.ts b/milvus/grpc/Database.ts index 11a23557..f9faea22 100644 --- a/milvus/grpc/Database.ts +++ b/milvus/grpc/Database.ts @@ -40,7 +40,10 @@ export class Database extends BaseClient { const promise = await promisify( this.channelPool, 'CreateDatabase', - data, + { + db_name: data.db_name, + properties: parseToKeyValue(data.properties), + }, data.timeout || this.timeout ); return promise; diff --git a/milvus/types/Database.ts b/milvus/types/Database.ts index 87753eb9..87cd333b 100644 --- a/milvus/types/Database.ts +++ b/milvus/types/Database.ts @@ -7,7 +7,9 @@ export interface databaseReq extends GrpcTimeOut { } // request -export interface CreateDatabaseRequest extends databaseReq {} +export interface CreateDatabaseRequest extends databaseReq { + properties?: Properties; // optional, properties +} export interface DropDatabasesRequest extends databaseReq {} export interface DescribeDatabaseRequest extends databaseReq {} diff --git a/test/grpc/Database.spec.ts b/test/grpc/Database.spec.ts index 73024419..ac5c83b7 100644 --- a/test/grpc/Database.spec.ts +++ b/test/grpc/Database.spec.ts @@ -1,4 +1,4 @@ -import { MilvusClient, ErrorCode, DEFAULT_DB } from '../../milvus'; +import { MilvusClient, ErrorCode, DEFAULT_DB, formatKeyValueData } from '../../milvus'; import { IP, genCollectionParams, @@ -10,6 +10,7 @@ let milvusClient = new MilvusClient({ address: IP, logLevel: 'info' }); const DEFAULT = 'default'; const DB_NAME = GENERATE_NAME('database'); const DB_NAME2 = GENERATE_NAME('database'); +const DB_WITH_PROPERTY = GENERATE_NAME(); const COLLECTION_NAME = GENERATE_NAME(); const COLLECTION_NAME2 = GENERATE_NAME(); @@ -272,6 +273,34 @@ describe(`Database API`, () => { ]); }); + it(`create db with property set should be successful`, async () => { + const res = await milvusClient.createDatabase({ + db_name: DB_WITH_PROPERTY, + properties: { + 'replicate.id': "local-mac", + }, + }); + expect(res.error_code).toEqual(ErrorCode.SUCCESS); + + const describe = await milvusClient.describeDatabase({ + db_name: DB_WITH_PROPERTY, + }); + + console.dir(describe, { depth: null }); + expect( + Number( + formatKeyValueData(describe.properties, ['replicate.id'])[ + 'replicate.id' + ] + ) + ).toEqual("local-mac"); + + // drop collection + await milvusClient.dropDatabase({ + db_name: DB_WITH_PROPERTY, + }); + }); + // it(`drop database should be ok`, async () => { // const all = await milvusClient.listDatabases();