Files
twenty_crm/server/src/tenant/entity-resolver/utils/generate-args-input.util.ts
Jérémy M 3e83cb6846 feat: conditional filtering & aggregation support & data ordering support (#2107)
* feat: wip

* feat: add filter on findOne

* fix: tests & small bug

* feat: add test and support aggregation

* feat: add order by support

* fix: fix comments

* fix: tests
2023-10-19 15:24:36 +02:00

31 lines
887 B
TypeScript

import { stringifyWithoutKeyQuote } from './stringify-without-key-quote.util';
export const generateArgsInput = (args: any) => {
let argsString = '';
for (const key in args) {
// Check if the value is not undefined
if (args[key] === undefined) {
continue;
}
if (typeof args[key] === 'string') {
// If it's a string, add quotes
argsString += `${key}: "${args[key]}", `;
} else if (typeof args[key] === 'object' && args[key] !== null) {
// If it's an object (and not null), stringify it
argsString += `${key}: ${stringifyWithoutKeyQuote(args[key])}, `;
} else {
// For other types (number, boolean), add as is
argsString += `${key}: ${args[key]}, `;
}
}
// Remove trailing comma and space, if present
if (argsString.endsWith(', ')) {
argsString = argsString.slice(0, -2);
}
return argsString;
};