Clean up MongoDB query projection

This prevents potential 'path collision' errors from MongoDB.
This commit is contained in:
Zaid Abdulla committed 2022-02-17 18:14:53 -08:00
1 parent adaf801d6e
commit 2b37f11e2e
3 files changed
+7 -3

No files matched your search

+3 -1
View File
@@ -91,7 +91,9 @@ export async function disconnect(): Promise<void> {
// Optimize projection by removing overlaps
// This can modify the object
function optimizeProjection(obj: { [path: string]: 1 }): { [path: string]: 1 } {
export function optimizeProjection(obj: { [path: string]: 1 }): {
[path: string]: 1;
} {
if (obj[""]) return { "": obj[""] };
const keys = Object.keys(obj).sort();