Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support the properties param in the create database api #379

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion milvus/grpc/Database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion milvus/types/Database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}

Expand Down
30 changes: 29 additions & 1 deletion test/grpc/Database.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MilvusClient, ErrorCode, DEFAULT_DB } from '../../milvus';
import { MilvusClient, ErrorCode, DEFAULT_DB, formatKeyValueData } from '../../milvus';
import {
IP,
genCollectionParams,
Expand All @@ -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();

Expand Down Expand Up @@ -272,6 +273,33 @@ 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,
});

expect(
String(
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();

Expand Down
Loading