test@mongolord> version()
|
4.0.1
|
test@mongolord> db.foo.validate
|
function (full) {
|
var cmd = {validate: this.getName()};
|
|
if (typeof(full) == 'object') // support arbitrary options here
|
Object.extend(cmd, full);
|
else
|
cmd.full = full;
|
|
var res = this._db.runCommand(cmd);
|
|
if (typeof(res.valid) == 'undefined') {
|
// old-style format just put everything in a string. Now using proper fields
|
|
res.valid = false;
|
|
var raw = res.result || res.raw;
|
|
if (raw) {
|
var str = "-" + tojson(raw);
|
res.valid = !(str.match(/exception/) || str.match(/corrupt/));
|
|
var p = /lastExtentSize:(\d+)/;
|
var r = p.exec(str);
|
if (r) {
|
res.lastExtentSize = Number(r[1]);
|
}
|
}
|
}
|
|
return res;
|
}
|