@hf-chimera/store
Version:
Cross-end reactivity API
45 lines (43 loc) • 1.43 kB
JavaScript
import { c as chimeraCreateConjunction, l as chimeraCreateNot, o as chimeraCreateOrderBy, s as ChimeraOrderNulls, u as chimeraCreateOperator } from "./src-C74sq0jQ.js";
//#region packages/qb/index.ts
var ChimeraQueryBuilder = class ChimeraQueryBuilder {
orderRules = [];
orderBy(key, desc = false, nulls = ChimeraOrderNulls.Last) {
this.orderRules.push(chimeraCreateOrderBy(key, desc, nulls));
return this;
}
filters = [];
rootConjunction = "and";
conjunction(type) {
this.rootConjunction = type;
}
buildFilter() {
return this.filters.length ? chimeraCreateConjunction(this.rootConjunction, this.filters) : null;
}
where(value, op, test) {
this.filters.push(chimeraCreateOperator(op, value, test));
return this;
}
group(conjunction, builder) {
const isNot = conjunction === "not";
const nestedBuilder = new ChimeraQueryBuilder();
!isNot && nestedBuilder.conjunction(conjunction);
builder(nestedBuilder);
const nestedQuery = nestedBuilder.buildFilter();
nestedQuery && this.filters.push(isNot ? chimeraCreateNot(nestedQuery) : nestedQuery);
return this;
}
whereNot(value, op, test) {
this.filters.push(chimeraCreateNot(chimeraCreateOperator(op, value, test)));
return this;
}
build() {
return {
filter: this.buildFilter(),
order: this.orderRules.length ? this.orderRules : null
};
}
};
//#endregion
export { ChimeraQueryBuilder as t };
//# sourceMappingURL=qb-pchs-vdM.js.map