getPkFieldType()
Addedv2.6.x
This operation returns the primary key field's data type for a collection. This is a convenient method that describes the collection and extracts the primary key field type.
await milvusClient.getPkFieldType(data: DescribeCollectionReq)
Request Syntax
getPkFieldType({
collection_name: string,
timeout: number
})
PARAMETERS:
-
collection_name (string) -
[REQUIRED]
The name of the collection.
-
timeout (number) -
RPC timeout in milliseconds. Optional.
RETURNS:
Promise<keyof typeof DataType>
The data type of the primary key field (e.g., "Int64", "VarChar").
Example
import { MilvusClient } from '@zilliz/milvus2-sdk-node';
const client = new MilvusClient({
address: 'YOUR_CLUSTER_ENDPOINT',
token: 'YOUR_CLUSTER_TOKEN',
});
const pkType = await client.getPkFieldType({
collection_name: 'my_collection',
});
console.log(pkType); // e.g., "Int64"