Clean up MongoDB query projection
This prevents potential 'path collision' errors from MongoDB.
This commit is contained in:
1 parent
adaf801d6e
commit
2b37f11e2e
3 files changed
+7
-3
No files matched your search
@@ -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();
|
||||
|
||||
Reference in new issue
Block a user