11type QueryTypesSingle = string | number | boolean ;
2- export type QueryTypesList = string [ ] | number [ ] | boolean [ ] | Query [ ] ;
2+ export type QueryTypesList = string [ ] | number [ ] | boolean [ ] | Query [ ] | any [ ] ;
33export type QueryTypes = QueryTypesSingle | QueryTypesList ;
44type AttributesTypes = string | string [ ] ;
55
@@ -52,20 +52,20 @@ export class Query {
5252 * Filter resources where attribute is equal to value.
5353 *
5454 * @param {string } attribute
55- * @param {QueryTypes } value
55+ * @param {QueryTypes | any[] } value
5656 * @returns {string }
5757 */
58- static equal = ( attribute : string , value : QueryTypes ) : string =>
58+ static equal = ( attribute : string , value : QueryTypes | any [ ] ) : string =>
5959 new Query ( "equal" , attribute , value ) . toString ( ) ;
6060
6161 /**
6262 * Filter resources where attribute is not equal to value.
6363 *
6464 * @param {string } attribute
65- * @param {QueryTypes } value
65+ * @param {QueryTypes | any[] } value
6666 * @returns {string }
6767 */
68- static notEqual = ( attribute : string , value : QueryTypes ) : string =>
68+ static notEqual = ( attribute : string , value : QueryTypes | any [ ] ) : string =>
6969 new Query ( "notEqual" , attribute , value ) . toString ( ) ;
7070
7171 /**
@@ -238,17 +238,17 @@ export class Query {
238238 * @param {string | string[] } value
239239 * @returns {string }
240240 */
241- static contains = ( attribute : string , value : string | string [ ] ) : string =>
241+ static contains = ( attribute : string , value : string | any [ ] ) : string =>
242242 new Query ( "contains" , attribute , value ) . toString ( ) ;
243243
244244 /**
245245 * Filter resources where attribute does not contain the specified value.
246246 *
247247 * @param {string } attribute
248- * @param {string | string [] } value
248+ * @param {string | any [] } value
249249 * @returns {string }
250250 */
251- static notContains = ( attribute : string , value : string | string [ ] ) : string =>
251+ static notContains = ( attribute : string , value : string | any [ ] ) : string =>
252252 new Query ( "notContains" , attribute , value ) . toString ( ) ;
253253
254254 /**
@@ -311,6 +311,16 @@ export class Query {
311311 static createdAfter = ( value : string ) : string =>
312312 new Query ( "createdAfter" , undefined , value ) . toString ( ) ;
313313
314+ /**
315+ * Filter resources where document was created between dates.
316+ *
317+ * @param {string } start
318+ * @param {string } end
319+ * @returns {string }
320+ */
321+ static createdBetween = ( start : string , end : string ) : string =>
322+ new Query ( "createdBetween" , undefined , [ start , end ] as QueryTypesList ) . toString ( ) ;
323+
314324 /**
315325 * Filter resources where document was updated before date.
316326 *
@@ -329,6 +339,16 @@ export class Query {
329339 static updatedAfter = ( value : string ) : string =>
330340 new Query ( "updatedAfter" , undefined , value ) . toString ( ) ;
331341
342+ /**
343+ * Filter resources where document was updated between dates.
344+ *
345+ * @param {string } start
346+ * @param {string } end
347+ * @returns {string }
348+ */
349+ static updatedBetween = ( start : string , end : string ) : string =>
350+ new Query ( "updatedBetween" , undefined , [ start , end ] as QueryTypesList ) . toString ( ) ;
351+
332352 /**
333353 * Combine multiple queries using logical OR operator.
334354 *
@@ -346,4 +366,132 @@ export class Query {
346366 */
347367 static and = ( queries : string [ ] ) =>
348368 new Query ( "and" , undefined , queries . map ( ( query ) => JSON . parse ( query ) ) ) . toString ( ) ;
369+
370+ /**
371+ * Filter resources where attribute is at a specific distance from the given coordinates.
372+ *
373+ * @param {string } attribute
374+ * @param {any[] } values
375+ * @param {number } distance
376+ * @param {boolean } meters
377+ * @returns {string }
378+ */
379+ static distanceEqual = ( attribute : string , values : any [ ] , distance : number , meters : boolean = true ) : string =>
380+ new Query ( "distanceEqual" , attribute , [ [ values , distance , meters ] ] as QueryTypesList ) . toString ( ) ;
381+
382+ /**
383+ * Filter resources where attribute is not at a specific distance from the given coordinates.
384+ *
385+ * @param {string } attribute
386+ * @param {any[] } values
387+ * @param {number } distance
388+ * @param {boolean } meters
389+ * @returns {string }
390+ */
391+ static distanceNotEqual = ( attribute : string , values : any [ ] , distance : number , meters : boolean = true ) : string =>
392+ new Query ( "distanceNotEqual" , attribute , [ [ values , distance , meters ] ] as QueryTypesList ) . toString ( ) ;
393+
394+ /**
395+ * Filter resources where attribute is at a distance greater than the specified value from the given coordinates.
396+ *
397+ * @param {string } attribute
398+ * @param {any[] } values
399+ * @param {number } distance
400+ * @param {boolean } meters
401+ * @returns {string }
402+ */
403+ static distanceGreaterThan = ( attribute : string , values : any [ ] , distance : number , meters : boolean = true ) : string =>
404+ new Query ( "distanceGreaterThan" , attribute , [ [ values , distance , meters ] ] as QueryTypesList ) . toString ( ) ;
405+
406+ /**
407+ * Filter resources where attribute is at a distance less than the specified value from the given coordinates.
408+ *
409+ * @param {string } attribute
410+ * @param {any[] } values
411+ * @param {number } distance
412+ * @param {boolean } meters
413+ * @returns {string }
414+ */
415+ static distanceLessThan = ( attribute : string , values : any [ ] , distance : number , meters : boolean = true ) : string =>
416+ new Query ( "distanceLessThan" , attribute , [ [ values , distance , meters ] ] as QueryTypesList ) . toString ( ) ;
417+
418+ /**
419+ * Filter resources where attribute intersects with the given geometry.
420+ *
421+ * @param {string } attribute
422+ * @param {any[] } values
423+ * @returns {string }
424+ */
425+ static intersects = ( attribute : string , values : any [ ] ) : string =>
426+ new Query ( "intersects" , attribute , [ values ] ) . toString ( ) ;
427+
428+ /**
429+ * Filter resources where attribute does not intersect with the given geometry.
430+ *
431+ * @param {string } attribute
432+ * @param {any[] } values
433+ * @returns {string }
434+ */
435+ static notIntersects = ( attribute : string , values : any [ ] ) : string =>
436+ new Query ( "notIntersects" , attribute , [ values ] ) . toString ( ) ;
437+
438+ /**
439+ * Filter resources where attribute crosses the given geometry.
440+ *
441+ * @param {string } attribute
442+ * @param {any[] } values
443+ * @returns {string }
444+ */
445+ static crosses = ( attribute : string , values : any [ ] ) : string =>
446+ new Query ( "crosses" , attribute , [ values ] ) . toString ( ) ;
447+
448+ /**
449+ * Filter resources where attribute does not cross the given geometry.
450+ *
451+ * @param {string } attribute
452+ * @param {any[] } values
453+ * @returns {string }
454+ */
455+ static notCrosses = ( attribute : string , values : any [ ] ) : string =>
456+ new Query ( "notCrosses" , attribute , [ values ] ) . toString ( ) ;
457+
458+ /**
459+ * Filter resources where attribute overlaps with the given geometry.
460+ *
461+ * @param {string } attribute
462+ * @param {any[] } values
463+ * @returns {string }
464+ */
465+ static overlaps = ( attribute : string , values : any [ ] ) : string =>
466+ new Query ( "overlaps" , attribute , [ values ] ) . toString ( ) ;
467+
468+ /**
469+ * Filter resources where attribute does not overlap with the given geometry.
470+ *
471+ * @param {string } attribute
472+ * @param {any[] } values
473+ * @returns {string }
474+ */
475+ static notOverlaps = ( attribute : string , values : any [ ] ) : string =>
476+ new Query ( "notOverlaps" , attribute , [ values ] ) . toString ( ) ;
477+
478+ /**
479+ * Filter resources where attribute touches the given geometry.
480+ *
481+ * @param {string } attribute
482+ * @param {any[] } values
483+ * @returns {string }
484+ */
485+ static touches = ( attribute : string , values : any [ ] ) : string =>
486+ new Query ( "touches" , attribute , [ values ] ) . toString ( ) ;
487+
488+ /**
489+ * Filter resources where attribute does not touch the given geometry.
490+ *
491+ * @param {string } attribute
492+ * @param {any[] } values
493+ * @returns {string }
494+ */
495+ static notTouches = ( attribute : string , values : any [ ] ) : string =>
496+ new Query ( "notTouches" , attribute , [ values ] ) . toString ( ) ;
349497}
0 commit comments