mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-10 15:58:38 +01:00
13 lines
409 B
TypeScript
13 lines
409 B
TypeScript
|
|
|
|
export function getPrettyAggregation(aggregation: any[], indent: number = 0) {
|
|
const text = JSON.stringify(aggregation, null, indent);
|
|
const result = text.replace(
|
|
/"(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z)"/g,
|
|
(match, date) => `ISODate("${date}")`
|
|
).replace(
|
|
/"([a-fA-F0-9]{24})"/g,
|
|
(match, objectId) => `ObjectId("${objectId}")`
|
|
);
|
|
return result;
|
|
} |