dto.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import {
  2. IsNotEmpty,
  3. IsString,
  4. IsBoolean,
  5. IsOptional,
  6. IsArray,
  7. ArrayNotEmpty,
  8. IsEnum,
  9. } from 'class-validator';
  10. import {
  11. FieldType,
  12. ShowCollectionsType,
  13. } from '@zilliz/milvus2-sdk-node/dist/milvus/types/Collection'; // todo: need improve like export types in root file.
  14. import { DataType } from '@zilliz/milvus2-sdk-node/dist/milvus/types/Common';
  15. import { ApiProperty } from '@nestjs/swagger';
  16. export class CreateCollection {
  17. @ApiProperty({
  18. description: 'Milvus collection name',
  19. })
  20. @IsString()
  21. @IsNotEmpty({
  22. message: 'collection_name is empty',
  23. })
  24. readonly collection_name: string;
  25. @ApiProperty({
  26. description: 'Generate ID automatically by milvus',
  27. type: Boolean,
  28. })
  29. @IsBoolean()
  30. @IsOptional()
  31. readonly autoID: boolean;
  32. @ApiProperty({
  33. description: 'Field data type',
  34. enum: DataType,
  35. })
  36. @IsArray()
  37. @ArrayNotEmpty()
  38. @IsNotEmpty({
  39. message: 'fields is empty',
  40. })
  41. readonly fields: FieldType[];
  42. }
  43. export class ShowCollections {
  44. @ApiProperty({
  45. description: 'Type allow all->0 inmemory->1',
  46. enum: ShowCollectionsType,
  47. })
  48. @IsOptional()
  49. @IsEnum(ShowCollectionsType, { message: 'Type allow all->0 inmemory->1' })
  50. readonly type: ShowCollectionsType;
  51. }
  52. export class InsertData {
  53. @ApiProperty({
  54. description: 'Partition in this collection',
  55. })
  56. @IsOptional()
  57. readonly partition_names: string[];
  58. @ApiProperty({
  59. description: 'The fields data in this collection',
  60. default: [{ vector: [1, 2, 3], a: 1, b: 2 }],
  61. })
  62. readonly fields_data: any[];
  63. }