@ronin/compiler
Advanced tools
Comparing version 0.8.8-leo-ron-1083-experimental-193 to 0.8.8-leo-ron-1083-experimental-194
@@ -1356,3 +1356,3 @@ // src/utils/helpers.ts | ||
statements; | ||
models; | ||
models = []; | ||
queries; | ||
@@ -1362,3 +1362,2 @@ constructor(queries, options) { | ||
this.statements = this.compileQueries(queries, models, options); | ||
this.models = models; | ||
this.queries = queries; | ||
@@ -1400,13 +1399,23 @@ } | ||
} | ||
this.models = modelListWithPresets; | ||
return [...dependencyStatements, ...mainStatements]; | ||
}; | ||
formatRecord(model, record) { | ||
const formattedRecord = { ...record }; | ||
for (const key in record) { | ||
const { field } = getFieldFromModel(model, key, "to"); | ||
if (field.type === "json") { | ||
formattedRecord[key] = JSON.parse(record[key]); | ||
continue; | ||
} | ||
formattedRecord[key] = record[key]; | ||
} | ||
return expand(formattedRecord); | ||
} | ||
formatOutput(results) { | ||
return results.map((result, index) => { | ||
const query = this.queries.at(-index); | ||
const { queryType, queryModel } = splitQuery(query); | ||
const { queryModel } = splitQuery(query); | ||
const model = getModelBySlug(this.models, queryModel); | ||
const single = queryModel !== model.pluralSlug; | ||
if (single) return { record: result[0] }; | ||
if (queryType === "count") return { amount: result[0] }; | ||
return { records: result }; | ||
return { record: this.formatRecord(model, result[0]) }; | ||
}); | ||
@@ -1413,0 +1422,0 @@ } |
{ | ||
"name": "@ronin/compiler", | ||
"version": "0.8.8-leo-ron-1083-experimental-193", | ||
"version": "0.8.8-leo-ron-1083-experimental-194", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "description": "Compiles RONIN queries to SQL statements.", |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
445654
7428