UNPKG

weaviate-client

Version:
29 lines (28 loc) • 906 B
import { CommandBase } from '../validation/commandBase.js'; import { isValidStringProperty } from '../validation/string.js'; export default class ClassDeleter extends CommandBase { className; constructor(client) { super(client); } withClassName = (className) => { this.className = className; return this; }; validateClassName = () => { if (!isValidStringProperty(this.className)) { this.addError('className must be set - set with .withClassName(className)'); } }; validate = () => { this.validateClassName(); }; do = () => { this.validate(); if (this.errors.length > 0) { return Promise.reject(new Error('invalid usage: ' + this.errors.join(', '))); } const path = `/schema/${this.className}`; return this.client.delete(path, undefined, false); }; }