On this page本页内容
db.collection.validate(<documents>)¶mongo Shell Method方法
This page documents the 本页记录了mongo shell method, and does not refer to the MongoDB Node.js driver (or any other driver) method. mongo shell方法,未提及MongoDB Node.js驱动程序(或任何其他驱动程序)方法。For corresponding MongoDB driver API, refer to your specific MongoDB driver documentation instead.有关相应的MongoDB驱动程序API,请参阅特定的MongoDB驱动程序文档。
Validates a collection. 验证集合。The method scans a collection data and indexes for correctness and returns the result. 该方法扫描集合数据和索引的正确性,并返回结果。For details of the output, see Validate Output.有关输出的详细信息,请参阅验证输出。
The db.collection.validate() method is a wrapper around the validate command.db.collection.validate()方法是validate命令的包装器。
Changed in version 4.4在版本4.4中更改
db.collection.validate() no longer accepts just a boolean parameter. db.collection.validate()不再只接受布尔参数。See db.collection.validate() Parameter Change.请参阅db.collection.validate()参数更改。
The db.collection.validate() method has the following syntax:db.collection.validate()方法的语法如下所示:
The db.collection.validate() method can take the following optional document parameter with the fields:db.collection.validate()方法可以在字段中使用以下可选文档参数:
| full | boolean | Optional.
|
The db.collection.validate() method is potentially resource intensive and may impact the performance of your MongoDB instance.db.collection.validate()方法可能会占用大量资源,可能会影响MongoDB实例的性能。
The db.collection.validate() method obtains an exclusive lock on the collection. db.collection.validate()方法获取集合的独占锁。This will block all reads and writes on the collection until the operation finishes. 这将阻止集合上的所有读写操作,直到操作完成。When run on a secondary, the operation can block all other operations on that secondary until it finishes.在辅助设备上运行时,该操作可以阻止该辅助设备上的所有其他操作,直到完成。
The db.collection.validate() method can be slow, particularly on larger data sets.db.collection.validate()方法可能很慢,尤其是在较大的数据集上。
Starting in version MongoDB 4.4,从MongoDB 4.4版开始,
$currentOp and the currentOp command include dataThroughputAverage and dataThroughputLastSecond information for validate operations in progress.$currentOp和currentOp命令包括dataThroughputAverage和dataThroughputLastSecond信息,用于验证正在进行的操作。dataThroughputAverage and dataThroughputLastSecond information.dataThroughputAverage和dataThroughputLastSecond信息。myCollection using the default settings (i.e. { full: false } ){ full: false })验证集合myCollection的步骤
myCollection, specify full: true.myCollection执行完整验证,请指定full:true。For details of the output, see Validate Output.有关输出的详细信息,请参阅验证输出。