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
+2
-1
@@ -21,7 +21,7 @@ import * as url from "url";
|
||||
import { Collection, GridFSBucket, ObjectId } from "mongodb";
|
||||
import * as vm from "vm";
|
||||
import * as config from "./config";
|
||||
import { onConnect } from "./db";
|
||||
import { onConnect, optimizeProjection } from "./db";
|
||||
import * as query from "./query";
|
||||
import * as apiFunctions from "./api-functions";
|
||||
import { IncomingMessage, ServerResponse } from "http";
|
||||
@@ -821,6 +821,7 @@ export function listener(
|
||||
projection = {};
|
||||
for (const p of (urlParts.query.projection as string).split(","))
|
||||
projection[p.trim()] = 1;
|
||||
projection = optimizeProjection(projection);
|
||||
}
|
||||
|
||||
const cur = collection.find(q, { projection: projection });
|
||||
|
||||
Reference in new issue
Block a user