contensis-core-api
Version:
A dependency library used by contensis-delivery-api and contensis-management-api
32 lines (31 loc) • 1.04 kB
JavaScript
import { WhereExpression } from './Operators';
import { serializeOrder } from './QueryTypes';
export class ManagementQuery {
where = new WhereExpression();
orderBy = [];
pageIndex = 0;
pageSize = 20;
includeArchived = false;
includeDeleted = false;
aggregations = {};
constructor(...whereExpressions) {
if (whereExpressions) {
this.where.addRange(whereExpressions);
}
}
toJSON() {
const result = {};
result.pageIndex = this.pageIndex;
result.pageSize = this.pageSize;
const orderByDtos = serializeOrder(this.orderBy);
if (orderByDtos && orderByDtos.length > 0) {
result.orderBy = orderByDtos;
}
result.where = this.where;
result.includeArchived = this.includeArchived;
result.includeDeleted = this.includeDeleted;
if (Object.keys(this.aggregations || {}).length)
result.aggregations = this.aggregations;
return result;
}
}