@loomcore/api 0.1.113 → 0.1.115

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.
@@ -1,5 +1,6 @@
1
1
  import { LeftJoin } from "../../operations/left-join.operation.js";
2
2
  import { InnerJoin } from "../../operations/inner-join.operation.js";
3
+ import { LeftJoinMany } from "../../operations/left-join-many.operation.js";
3
4
  import { toSnakeCase } from "./convert-keys.util.js";
4
5
  function convertFieldToSnakeCase(field) {
5
6
  if (field.startsWith("_")) {
@@ -10,7 +11,7 @@ function convertFieldToSnakeCase(field) {
10
11
  export function buildJoinClauses(operations, mainTableName) {
11
12
  let joinClauses = [];
12
13
  for (const operation of operations) {
13
- if (operation instanceof LeftJoin || operation instanceof InnerJoin) {
14
+ if (operation instanceof LeftJoin || operation instanceof InnerJoin || operation instanceof LeftJoinMany) {
14
15
  const localRef = convertFieldToSnakeCase(operation.localField);
15
16
  const foreignSnake = convertFieldToSnakeCase(operation.foreignField);
16
17
  const joinType = operation instanceof InnerJoin ? "INNER JOIN" : "LEFT JOIN";
@@ -19,5 +20,5 @@ export function buildJoinClauses(operations, mainTableName) {
19
20
  joinClauses.push(`${joinType} ${joinTable} ON ${leftSide} = ${operation.as}."${foreignSnake}"`);
20
21
  }
21
22
  }
22
- return joinClauses.join('\n');
23
+ return joinClauses.join(' ');
23
24
  }
@@ -29,12 +29,12 @@ export async function buildSelectClause(client, mainTableName, operations) {
29
29
  const mainTableColumns = await getTableColumns(client, mainTableName);
30
30
  const mainSelects = mainTableColumns.map(col => `"${mainTableName}"."${col}" AS "${col}"`);
31
31
  const joinSelects = [];
32
- for (const join of [...leftJoinOperations, ...leftJoinManyOperations, ...innerJoinOperations]) {
32
+ for (const join of [...leftJoinOperations, ...innerJoinOperations, ...leftJoinManyOperations]) {
33
33
  const joinColumns = await getTableColumns(client, join.from);
34
34
  for (const col of joinColumns) {
35
35
  joinSelects.push(`${join.as}."${col}" AS "${join.as}__${col}"`);
36
36
  }
37
37
  }
38
38
  const allSelects = [...mainSelects, ...joinSelects];
39
- return allSelects.join(',\n');
39
+ return allSelects.join(', ');
40
40
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loomcore/api",
3
- "version": "0.1.113",
3
+ "version": "0.1.115",
4
4
  "private": false,
5
5
  "description": "Loom Core Api - An opinionated Node.js api using Typescript, Express, and MongoDb or PostgreSQL",
6
6
  "scripts": {