Files
mongo/jstests/core/basic9.js

19 lines
632 B
JavaScript
Raw Normal View History

2013-11-14 09:13:38 -05:00
// Tests that $<prefix> field names are not allowed, but you can use a $ anywhere else.
t = db.getCollection("foo_basic9");
t.drop();
2013-11-14 09:13:38 -05:00
// more diagnostics on bad save, if exception fails
doBadSave = function(param) {
print("doing save with " + tojson(param));
var res = t.save(param);
2013-11-14 09:13:38 -05:00
// Should not get here.
print('Should have errored out: ' + tojson(res));
};
t.save({foo$foo: 5});
t.save({foo$: 5});
assert.throws(doBadSave, [{$foo: 5}], "key names aren't allowed to start with $ doesn't work");
2016-05-28 17:55:12 -04:00
assert.throws(
doBadSave, [{x: {$foo: 5}}], "embedded key names aren't allowed to start with $ doesn't work");