export const JSON_NIL = Symbol('null');export const IS_PARTIAL_INDEXING = Symbol('partial_indexing');export const SELECT_ALL = Symbol('select *');
export function cleanResults(results: any[]): any {
function cleanObj(obj: any) { if (!obj || typeof obj !== 'object') { return; } for (const [k, v] of Object.entries(obj)) { if (v === JSON_NIL) { obj[k] = null; } else if (Array.isArray(v)) { if ((v as any)[IS_PARTIAL_INDEXING]) { obj[k] = null; } else { for (let i = 0; i < v.length; i++) { if (obj[i] === JSON_NIL) { obj[i] = null; } else { cleanObj(v); } } } } else { cleanObj(v); } } }
for (let i = 0; i < results.length; i++) { const sel = results[i][SELECT_ALL]; if (sel) { results[i] = sel(); } cleanObj(results[i]); } return results;}