@@ -202,6 +202,14 @@ declare class StaticModel {
202202 */
203203 static params < M extends typeof Model > ( this : M , payload : Record < string , string | number | boolean > ) : InstanceType < M >
204204
205+ /**
206+ * Add a conditional clause to the query.
207+ *
208+ * @see {@link https://robsontenorio.github.io/vue-api-query/api/query-builder-methods#when|API Reference }
209+ * @see {@link https://robsontenorio.github.io/vue-api-query/building-the-query#conditional|Building the Query }
210+ */
211+ static when < M extends typeof Model , T = any > ( this : M , value : T , callback : ( query : Builder , value : T ) => any ) : InstanceType < M >
212+
205213 /**
206214 * Build custom endpoints.
207215 *
@@ -559,6 +567,14 @@ export class Model extends StaticModel {
559567 */
560568 params ( payload : Record < string , string | number | boolean > ) : this
561569
570+ /**
571+ * Add a conditional clause to the query.
572+ *
573+ * @see {@link https://robsontenorio.github.io/vue-api-query/api/query-builder-methods#when|API Reference }
574+ * @see {@link https://robsontenorio.github.io/vue-api-query/building-the-query#conditional|Building the Query }
575+ */
576+ when < T = any > ( value : T , callback : ( query : Builder , value : T ) => any ) : this
577+
562578 /**
563579 * Build custom endpoints.
564580 *
@@ -705,3 +721,156 @@ export class Model extends StaticModel {
705721 */
706722 sync ( params : Record < string , any > ) : Promise < any >
707723}
724+
725+ declare class Builder {
726+ /**
727+ * Query
728+ */
729+
730+ /**
731+ * Eager load relationships.
732+ *
733+ * @see {@link https://robsontenorio.github.io/vue-api-query/api/query-builder-methods#include|API Reference }
734+ * @see {@link https://robsontenorio.github.io/vue-api-query/building-the-query#including-relationships|Building the Query }
735+ */
736+ include ( ...relationships : string [ ] ) : this
737+
738+ /**
739+ * Eager load relationships.
740+ *
741+ * @see {@link https://robsontenorio.github.io/vue-api-query/api/query-builder-methods#include|API Reference }
742+ * @see {@link https://robsontenorio.github.io/vue-api-query/building-the-query#including-relationships|Building the Query }
743+ */
744+ include ( relationships : string [ ] ) : this
745+
746+ /**
747+ * Eager load relationships.
748+ *
749+ * Alias for the [include()]{@link include} method.
750+ *
751+ * @see {@link https://robsontenorio.github.io/vue-api-query/api/query-builder-methods#include|API Reference }
752+ * @see {@link https://robsontenorio.github.io/vue-api-query/building-the-query#including-relationships|Building the Query }
753+ */
754+ with ( ...relationships : string [ ] ) : this
755+
756+ /**
757+ * Eager load relationships.
758+ *
759+ * Alias for the [include()]{@link include} method.
760+ *
761+ * @see {@link https://robsontenorio.github.io/vue-api-query/api/query-builder-methods#include|API Reference }
762+ * @see {@link https://robsontenorio.github.io/vue-api-query/building-the-query#including-relationships|Building the Query }
763+ */
764+ with ( relationships : string [ ] ) : this
765+
766+ /**
767+ * Append attributes.
768+ *
769+ * @see {@link https://robsontenorio.github.io/vue-api-query/api/query-builder-methods#append|API Reference }
770+ * @see {@link https://robsontenorio.github.io/vue-api-query/building-the-query#appending-attributes|Building the Query }
771+ */
772+ append ( ...attributes : string [ ] ) : this
773+
774+ /**
775+ * Append attributes.
776+ *
777+ * @see {@link https://robsontenorio.github.io/vue-api-query/api/query-builder-methods#append|API Reference }
778+ * @see {@link https://robsontenorio.github.io/vue-api-query/building-the-query#appending-attributes|Building the Query }
779+ */
780+ append ( attributes : string [ ] ) : this
781+
782+ /**
783+ * Set the columns to be selected.
784+ *
785+ * @see {@link https://robsontenorio.github.io/vue-api-query/api/query-builder-methods#select|API Reference }
786+ * @see {@link https://robsontenorio.github.io/vue-api-query/building-the-query#selecting-fields|Building the Query }
787+ */
788+ select ( ...columns : string [ ] ) : this
789+
790+ /**
791+ * Set the columns to be selected.
792+ *
793+ * @see {@link https://robsontenorio.github.io/vue-api-query/api/query-builder-methods#select|API Reference }
794+ * @see {@link https://robsontenorio.github.io/vue-api-query/building-the-query#selecting-fields|Building the Query }
795+ */
796+ select ( columns : string [ ] ) : this
797+
798+ /**
799+ * Set the columns to be selected.
800+ *
801+ * @see {@link https://robsontenorio.github.io/vue-api-query/api/query-builder-methods#select|API Reference }
802+ * @see {@link https://robsontenorio.github.io/vue-api-query/building-the-query#selecting-fields|Building the Query }
803+ */
804+ select ( columns : {
805+ [ related : string ] : string [ ]
806+ } ) : this
807+
808+ /**
809+ * Add a basic where clause to the query.
810+ *
811+ * @see {@link https://robsontenorio.github.io/vue-api-query/api/query-builder-methods#where|API Reference }
812+ * @see {@link https://robsontenorio.github.io/vue-api-query/building-the-query#evaluating-a-single-value|Building the Query }
813+ */
814+ where ( field : string | string [ ] , value : string | number | boolean ) : this
815+
816+ /**
817+ * Add a "where in" clause to the query.
818+ *
819+ * @see {@link https://robsontenorio.github.io/vue-api-query/api/query-builder-methods#wherein|API Reference }
820+ * @see {@link https://robsontenorio.github.io/vue-api-query/building-the-query#evaluating-multiple-values|Building the Query }
821+ */
822+ whereIn ( field : string | string [ ] , array : ( string | number | boolean ) [ ] ) : this
823+
824+ /**
825+ * Add an "order by" clause to the query.
826+ *
827+ * @see {@link https://robsontenorio.github.io/vue-api-query/api/query-builder-methods#orderby|API Reference }
828+ * @see {@link https://robsontenorio.github.io/vue-api-query/building-the-query#sorting|Building the Query }
829+ */
830+ orderBy ( ...columns : string [ ] ) : this
831+
832+ /**
833+ * Add an "order by" clause to the query.
834+ *
835+ * @see {@link https://robsontenorio.github.io/vue-api-query/api/query-builder-methods#orderby|API Reference }
836+ * @see {@link https://robsontenorio.github.io/vue-api-query/building-the-query#sorting|Building the Query }
837+ */
838+ orderBy ( columns : string [ ] ) : this
839+
840+ /**
841+ * Set the current page.
842+ *
843+ * @see {@link https://robsontenorio.github.io/vue-api-query/api/query-builder-methods#page|API Reference }
844+ * @see {@link https://robsontenorio.github.io/vue-api-query/building-the-query#paginating|Building the Query }
845+ */
846+ page ( number : number ) : this
847+
848+ /**
849+ * Set the page limit.
850+ *
851+ * @see {@link https://robsontenorio.github.io/vue-api-query/api/query-builder-methods#limit|API Reference }
852+ * @see {@link https://robsontenorio.github.io/vue-api-query/building-the-query#paginating|Building the Query }
853+ */
854+ limit ( number : number ) : this
855+
856+ /**
857+ * Add custom parameters to the query.
858+ *
859+ * @see {@link https://robsontenorio.github.io/vue-api-query/api/query-builder-methods#params|API Reference }
860+ * @see {@link https://robsontenorio.github.io/vue-api-query/building-the-query#applying-custom-parameters|Building the Query }
861+ */
862+ params ( payload : Record < string , string | number | boolean > ) : this
863+
864+ /**
865+ * Add a conditional clause to the query.
866+ *
867+ * @see {@link https://robsontenorio.github.io/vue-api-query/api/query-builder-methods#when|API Reference }
868+ * @see {@link https://robsontenorio.github.io/vue-api-query/building-the-query#conditional|Building the Query }
869+ */
870+ when < T = any > ( value : T , callback : ( query : this, value : T ) => any ) : this
871+
872+ /**
873+ * Return parsed query string.
874+ */
875+ query ( ) : string
876+ }
0 commit comments