grafo-client
Version:
Grafo Client API Library
1 lines • 2.35 kB
JavaScript
var OpTypes=require("./op_type");function ResourceSearchCriteria(){this.limit=50,this.page=1}module.exports=ResourceSearchCriteria,ResourceSearchCriteria.prototype.setLimit=function(e){return this.limit=e,this},ResourceSearchCriteria.prototype.setPage=function(e){return this.page=e,this},ResourceSearchCriteria.prototype.setParent=function(e){return this.parent=e,this},ResourceSearchCriteria.prototype.setDeleted=function(e){return this.deleted=e,this},ResourceSearchCriteria.prototype.createdOn=function(e){return this.startDate=e,this.startDateOpType=OpTypes.getOpTypes().EQ,this},ResourceSearchCriteria.prototype.createdBefore=function(e){return this.startDate=e,this.startDateOpType=OpTypes.getOpTypes().LT,this},ResourceSearchCriteria.prototype.createdAfter=function(e){return this.startDate=e,this.startDateOpType=OpTypes.getOpTypes().GT,this},ResourceSearchCriteria.prototype.createdOnOrBefore=function(e){return this.startDate=e,this.startDateOpType=OpTypes.getOpTypes().LTE,this},ResourceSearchCriteria.prototype.createdOnOrAfter=function(e){return this.startDate=e,this.startDateOpType=OpTypes.getOpTypes().GTE,this},ResourceSearchCriteria.prototype.createdBetween=function(e,t,r){return this.startDate=e,this.endDate=t,r===OpTypes.InclusionType.IncludeStartDate?(this.startDateOpType=OpTypes.getOpTypes().GTE,this.endDateOpType=OpTypes.getOpTypes().LT):r===OpTypes.InclusionType.IncludeEndDate?(this.startDateOpType=OpTypes.getOpTypes().GT,this.endDateOpType=OpTypes.getOpTypes().LTE):r===OpTypes.InclusionType.IncludeStartAndEndDate?(this.startDateOpType=OpTypes.getOpTypes().GTE,this.endDateOpType=OpTypes.getOpTypes().LTE):this.createdBetween(e,t),this},ResourceSearchCriteria.prototype.createdBetween=function(e,t){return this.startDate=e,this.endDate=t,this.startDateOpType=OpTypes.getOpTypes().GT,this.endDateOpType=OpTypes.getOpTypes().LT,this},ResourceSearchCriteria.prototype.getQueryMap=function(){return this.queryMap={limit:this.limit,page:this.page,parent:this.parent,deleted:this.deleted},this.startDateOpType===OpTypes.getOpTypes().EQ?this.queryMap.created=this.startDate:(null!==this.startDate&&void 0!==this.startDate&&(this.queryMap["created["+this.startDateOpType.name+"]"]=this.startDate),null!==this.endDate&&void 0!==this.endDate&&(this.queryMap["created["+this.endDateOpType.name+"]"]=this.endDate)),this.queryMap};