12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- import { ChildrenStatusType, StatusEnum } from '../components/status/Types';
- import { CollectionView } from '../pages/collections/Types';
- import { IndexState } from '../types/Milvus';
- import BaseModel from './BaseModel';
- export class CollectionHttp extends BaseModel implements CollectionView {
- private autoID!: string;
- private collection_name!: string;
- private description!: string;
- private rowCount!: string;
- private index_status!: string;
- static COLLECTIONS_URL = '/collections';
- static COLLECTIONS_INDEX_STATUS_URL = '/collections/indexes/status';
- static CHECK_URL = '/milvus/check';
- constructor(props: CollectionView) {
- super(props);
- Object.assign(this, props);
- }
- static getCollections(): Promise<CollectionHttp[]> {
- return super.findAll({ path: this.COLLECTIONS_URL, params: {} });
- }
- static createCollection(data: any) {
- return super.create({ path: this.COLLECTIONS_URL, data });
- }
- static getCollectionsIndexState(): Promise<CollectionHttp[]> {
- return super.findAll({
- path: this.COLLECTIONS_INDEX_STATUS_URL,
- params: {},
- });
- }
- static deleteCollection(collectionName: string) {
- return super.delete({ path: `${this.COLLECTIONS_URL}/${collectionName}` });
- }
- static loadCollection(collectionName: string) {
- return super.update({
- path: `${this.COLLECTIONS_URL}/${collectionName}/load`,
- });
- }
- static releaseCollection(collectionName: string) {
- return super.update({
- path: `${this.COLLECTIONS_URL}/${collectionName}/release`,
- });
- }
- get _autoId() {
- return this.autoID;
- }
- get _desc() {
- return this.description;
- }
- get _id() {
- return '12';
- }
- get _name() {
- return this.collection_name;
- }
- get _rowCount() {
- return this.rowCount;
- }
- get _status() {
- return StatusEnum.loaded;
- }
- get _indexState() {
- switch (this.index_status) {
- case IndexState.InProgress:
- return ChildrenStatusType.CREATING;
- case IndexState.Failed:
- return ChildrenStatusType.ERROR;
- default:
- return ChildrenStatusType.FINISH;
- }
- }
- }
|