rads-db 3.2.38 → 3.2.40
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.
- package/integrations/node.cjs +6 -3
- package/integrations/node.mjs +8 -4
- package/package.json +1 -1
package/integrations/node.cjs
CHANGED
|
@@ -174,7 +174,7 @@ function getEntityTypesStrFromSchema(schema) {
|
|
|
174
174
|
if (type.isExtending && schema[type.isExtending]?.fields?.[f.name]) return "";
|
|
175
175
|
let fieldTypeStr = f.type;
|
|
176
176
|
if (f.isChange) fieldTypeStr = `Change<${fieldTypeStr}>`;
|
|
177
|
-
if (f.isRelation) fieldTypeStr = `Relation<${fieldTypeStr}>`;
|
|
177
|
+
if (f.isRelation) fieldTypeStr = `Relation<${fieldTypeStr}${f.relationDenormFields?.length ? `, ${f.relationDenormFields.map(x => `'${x}'`).join(" | ")}` : ""}>`;
|
|
178
178
|
if (f.isArray) fieldTypeStr = `${fieldTypeStr}[]`;
|
|
179
179
|
const fieldStr = ` ${f.name}${f.isRequired ? "" : "?"}: ${fieldTypeStr}`;
|
|
180
180
|
const commentStr2 = f.comment ? ` /** ${f.comment} */` : "";
|
|
@@ -216,9 +216,12 @@ function getWhereFieldsFor(schema, type, fieldKey) {
|
|
|
216
216
|
if (isArray) {
|
|
217
217
|
const arrayWhereFields = [`${name}_isEmpty?: boolean`];
|
|
218
218
|
if (!isRequired) arrayWhereFields.push(`${name}_isNull?: boolean`);
|
|
219
|
-
if (isPrimitive
|
|
219
|
+
if (isPrimitive) {
|
|
220
220
|
return [`${name}_arrayContains?: ${fieldTypeName}`, ...arrayWhereFields];
|
|
221
221
|
}
|
|
222
|
+
if (isEnum) {
|
|
223
|
+
return [`${name}_arrayContains?: string`, ...arrayWhereFields];
|
|
224
|
+
}
|
|
222
225
|
if (isRelation) {
|
|
223
226
|
return [`${name}_some?: ${getRelationWhereType()}`, ...arrayWhereFields];
|
|
224
227
|
}
|
|
@@ -239,7 +242,7 @@ function getWhereFieldsFor(schema, type, fieldKey) {
|
|
|
239
242
|
return [`${name}?: ${fieldTypeName}_Where`, ...commonWhereFields];
|
|
240
243
|
}
|
|
241
244
|
if (isEnum) {
|
|
242
|
-
return [`${name}?:
|
|
245
|
+
return [`${name}?: string`, `${name}_in?: string[]`, ...getWhereFieldsForString(fieldKey), ...commonWhereFields];
|
|
243
246
|
}
|
|
244
247
|
if (isPrimitive) {
|
|
245
248
|
return [`${name}?: ${fieldTypeName}`, `${name}_in?: ${fieldTypeName}[]`, ...getWhereFieldsForPrimitive(schema, type, fieldKey), ...commonWhereFields];
|
package/integrations/node.mjs
CHANGED
|
@@ -185,7 +185,8 @@ export function getEntityTypesStrFromSchema(schema) {
|
|
|
185
185
|
if (type.isExtending && schema[type.isExtending]?.fields?.[f.name]) return "";
|
|
186
186
|
let fieldTypeStr = f.type;
|
|
187
187
|
if (f.isChange) fieldTypeStr = `Change<${fieldTypeStr}>`;
|
|
188
|
-
if (f.isRelation)
|
|
188
|
+
if (f.isRelation)
|
|
189
|
+
fieldTypeStr = `Relation<${fieldTypeStr}${f.relationDenormFields?.length ? `, ${f.relationDenormFields.map((x) => `'${x}'`).join(" | ")}` : ""}>`;
|
|
189
190
|
if (f.isArray) fieldTypeStr = `${fieldTypeStr}[]`;
|
|
190
191
|
const fieldStr = ` ${f.name}${f.isRequired ? "" : "?"}: ${fieldTypeStr}`;
|
|
191
192
|
const commentStr2 = f.comment ? ` /** ${f.comment} */` : "";
|
|
@@ -222,9 +223,12 @@ function getWhereFieldsFor(schema, type, fieldKey) {
|
|
|
222
223
|
if (isArray) {
|
|
223
224
|
const arrayWhereFields = [`${name}_isEmpty?: boolean`];
|
|
224
225
|
if (!isRequired) arrayWhereFields.push(`${name}_isNull?: boolean`);
|
|
225
|
-
if (isPrimitive
|
|
226
|
+
if (isPrimitive) {
|
|
226
227
|
return [`${name}_arrayContains?: ${fieldTypeName}`, ...arrayWhereFields];
|
|
227
228
|
}
|
|
229
|
+
if (isEnum) {
|
|
230
|
+
return [`${name}_arrayContains?: string`, ...arrayWhereFields];
|
|
231
|
+
}
|
|
228
232
|
if (isRelation) {
|
|
229
233
|
return [`${name}_some?: ${getRelationWhereType()}`, ...arrayWhereFields];
|
|
230
234
|
}
|
|
@@ -250,8 +254,8 @@ function getWhereFieldsFor(schema, type, fieldKey) {
|
|
|
250
254
|
}
|
|
251
255
|
if (isEnum) {
|
|
252
256
|
return [
|
|
253
|
-
`${name}?:
|
|
254
|
-
`${name}_in?:
|
|
257
|
+
`${name}?: string`,
|
|
258
|
+
`${name}_in?: string[]`,
|
|
255
259
|
...getWhereFieldsForString(fieldKey),
|
|
256
260
|
...commonWhereFields
|
|
257
261
|
];
|