weaviate-client
Version:
JS/TS client for Weaviate
31 lines (30 loc) • 890 B
JavaScript
import { CommandBase } from '../validation/commandBase.js';
export default class ClassificationsGetter extends CommandBase {
id;
constructor(client) {
super(client);
}
withId = (id) => {
this.id = id;
return this;
};
validateIsSet = (prop, name, setter) => {
if (prop == undefined || prop == null || prop.length == 0) {
this.addError(`${name} must be set - set with ${setter}`);
}
};
validateId = () => {
this.validateIsSet(this.id, 'id', '.withId(id)');
};
validate = () => {
this.validateId();
};
do = () => {
this.validate();
if (this.errors.length > 0) {
return Promise.reject(new Error('invalid usage: ' + this.errors.join(', ')));
}
const path = `/classifications/${this.id}`;
return this.client.get(path);
};
}