@carbonorm/carbonnode 3.6.7 → 3.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -52,7 +52,16 @@ export abstract class ConditionBuilder<
52
52
  C6C.IS, C6C.IS_NOT,
53
53
  C6C.BETWEEN, 'NOT BETWEEN',
54
54
  C6C.MATCH_AGAINST,
55
- C6C.ST_DISTANCE_SPHERE
55
+ C6C.ST_DISTANCE_SPHERE,
56
+ // spatial predicates
57
+ C6C.ST_CONTAINS,
58
+ C6C.ST_INTERSECTS,
59
+ C6C.ST_WITHIN,
60
+ C6C.ST_CROSSES,
61
+ C6C.ST_DISJOINT,
62
+ C6C.ST_EQUALS,
63
+ C6C.ST_OVERLAPS,
64
+ C6C.ST_TOUCHES
56
65
  ]);
57
66
 
58
67
  private isTableReference(val: any): boolean {
@@ -113,6 +122,19 @@ export abstract class ConditionBuilder<
113
122
  const threshold = Array.isArray(value) ? value[0] : value;
114
123
  return `ST_Distance_Sphere(${col1}, ${col2}) < ${this.addParam(params, '', threshold)}`;
115
124
  }
125
+ if ([
126
+ C6C.ST_CONTAINS,
127
+ C6C.ST_INTERSECTS,
128
+ C6C.ST_WITHIN,
129
+ C6C.ST_CROSSES,
130
+ C6C.ST_DISJOINT,
131
+ C6C.ST_EQUALS,
132
+ C6C.ST_OVERLAPS,
133
+ C6C.ST_TOUCHES
134
+ ].includes(column)) {
135
+ const [geom1, geom2] = op;
136
+ return `${column}(${geom1}, ${geom2})`;
137
+ }
116
138
  }
117
139
 
118
140
  const leftIsCol = this.isColumnRef(column);
@@ -16,3 +16,19 @@ export const fieldEq = (leftCol: string, rightCol: string, leftAlias: string, ri
16
16
  // ST_Distance_Sphere for aliased fields
17
17
  export const distSphere = (fromCol: string, toCol: string, fromAlias: string, toAlias: string): any[] =>
18
18
  [C6C.ST_DISTANCE_SPHERE, F(fromCol, fromAlias), F(toCol, toAlias)];
19
+
20
+ // Build a bounding-box expression.
21
+ //
22
+ // Arguments must be provided in `(minLng, minLat, maxLng, maxLat)` order. The
23
+ // helper does not attempt to swap or validate coordinates; if a minimum value
24
+ // is greater than its corresponding maximum value, MySQL's `ST_MakeEnvelope`
25
+ // returns `NULL`.
26
+ export const bbox = (minLng: number, minLat: number, maxLng: number, maxLat: number): any[] =>
27
+ [C6C.ST_SRID, [C6C.ST_MAKEENVELOPE,
28
+ [C6C.ST_POINT, minLng, minLat],
29
+ [C6C.ST_POINT, maxLng, maxLat]], 4326];
30
+
31
+ // ST_Contains for map envelope/shape queries
32
+ export const stContains = (envelope: string, shape: string): any[] =>
33
+ [C6C.ST_CONTAINS, envelope, shape];
34
+
@@ -7,6 +7,7 @@ import {Modify} from "./modifyTypes";
7
7
  import {JoinType, OrderDirection, SQLComparisonOperator, SQLFunction} from "./mysqlTypes";
8
8
  import {CarbonReact} from "@carbonorm/carbonreact";
9
9
  import {OrmGenerics} from "./ormGenerics";
10
+ import {restOrm} from "../restOrm";
10
11
 
11
12
  export type iRestMethods = 'GET' | 'POST' | 'PUT' | 'DELETE';
12
13
  export const POST = 'POST';
@@ -255,8 +256,11 @@ export interface iC6Object<
255
256
  [K in Extract<keyof RestTableInterfaces, string>]: C6RestfulModel<K, RestTableInterfaces[K], keyof RestTableInterfaces[K] & string>;
256
257
  };
257
258
  PREFIX: string;
258
- IMPORT: (tableName: string) => Promise<iDynamicApiImport>;
259
-
259
+ ORM: {
260
+ [K in Extract<keyof RestTableInterfaces, string>]:
261
+ C6RestfulModel<K, RestTableInterfaces[K], keyof RestTableInterfaces[K] & string>
262
+ & ReturnType<typeof restOrm<OrmGenerics<any>>>
263
+ }[]
260
264
  [key: string]: any;
261
265
  }
262
266