Files
mongo/jstests/core/query/where/where5.js
Steve McClure 1ffbc6c2e9 SERVER-109432: Autofix JS var usage to favor let (#40637)
GitOrigin-RevId: 9674b7db36a0f3f650d39c1e3fb2ad6ff2141cfb
2025-08-28 19:21:01 +00:00

36 lines
892 B
JavaScript

// Tests toString() in object constructor.
// Verifies that native functions do not expose the _native_function and _native_data properties.
// @tags: [
// # Uses $where operator
// requires_scripting,
// requires_getmore,
// ]
let t = db.where5;
t.drop();
t.save({a: 1});
// Prints information on the document's _id field.
function printIdConstructor(doc) {
// If doc is undefined, this function is running inside server.
if (!doc) {
doc = this;
}
// Verify that function and data fields are hidden.
assert(!("_native_function" in sleep));
assert(!("_native_data" in sleep));
// Predicate for matching document in collection.
return true;
}
print("Running JS function in server...");
assert.eq(t.find({$where: printIdConstructor}).itcount(), 1);
print("Running JS function in client...");
let doc = t.findOne();
printIdConstructor(doc);