weaviate-client
Version:
JS/TS client for Weaviate
50 lines (49 loc) • 1.36 kB
JavaScript
import { CommandBase } from '../validation/commandBase.js';
export default class Getter extends CommandBase {
additional;
after;
className;
limit;
tenant;
objectsPath;
constructor(client, objectsPath) {
super(client);
this.objectsPath = objectsPath;
this.additional = [];
}
withClassName = (className) => {
this.className = className;
return this;
};
withAfter = (id) => {
this.after = id;
return this;
};
withLimit = (limit) => {
this.limit = limit;
return this;
};
withTenant = (tenant) => {
this.tenant = tenant;
return this;
};
extendAdditional = (prop) => {
this.additional = [...this.additional, prop];
return this;
};
withAdditional = (additionalFlag) => this.extendAdditional(additionalFlag);
withVector = () => this.extendAdditional('vector');
validate() {
// nothing to validate
}
do = () => {
if (this.errors.length > 0) {
return Promise.reject(new Error('invalid usage: ' + this.errors.join(', ')));
}
return this.objectsPath
.buildGet(this.className, this.limit, this.additional, this.after, this.tenant)
.then((path) => {
return this.client.get(path);
});
};
}