let dbInvalidName = 'system_namespaces_invalidations';
|
let dbInvalid = db.getSiblingDB(dbInvalidName);
|
let num_collections = 3;
|
dbInvalid.dropDatabase();
|
for (let i = 0; i < num_collections; i++) {
|
assert.commandWorked(dbInvalid.createCollection('coll' + i.toString()));
|
}
|
let cmd = {find: 'system.namespaces'};
|
Object.extend(cmd, {batchSize: 3, showRecordId: true});
|
let res = dbInvalid.runCommand(cmd);
|
assert.commandWorked(res, 'could not run ' + tojson(cmd));
|
printjson(res);
|
let cursor = new DBCommandCursor(dbInvalid.getMongo(), res);
|
let errMsg =
|
'expected more data from command ' + tojson(cmd) + ', with result ' + tojson(res);
|
assert(cursor.hasNext(), errMsg);
|
let coll = dbInvalid['coll1'];
|
let modCmd ={collMod: 'coll1', validator: { $or:
|
[
|
{ phone: { $type: "string" } },
|
{ email: { $regex: /@mongodb\.com$/ } },
|
{ status: { $in: [ "Unknown", "Incomplete" ] } },
|
{ address: { $type: "string" } },
|
{ ssn: { $type: "string" } },
|
{ favoriteBook: { $type: "string" } },
|
{ favoriteColor: { $type: "string" } },
|
{ favoriteBeverage: { $type: "string" } },
|
{ favoriteDay: { $type: "string" } },
|
{ favoriteFood: { $type: "string" } },
|
{ favoriteSport: { $type: "string" } },
|
{ favoriteMovie: { $type: "string" } },
|
{ favoriteShow: { $type: "string" } }
|
]
|
}};
|
assert.commandWorked(dbInvalid.runCommand(modCmd));
|
assert.gt(cursor.itcount(), 0, errMsg);
|