>>>>>>> cn
翻译或纠错本页面

captrunc

On this page

Definition

captrunc

captrunc is a command that truncates capped collections for diagnostic and testing purposes and is not part of the stable client facing API. The command takes the following form:

{ captrunc: "<collection>", n: <integer>, inc: <true|false> }.

captrunc has the following fields:

Field Type Description
captrunc string The name of the collection to truncate.
n integer The number of documents to remove from the collection.
inc boolean Specifies whether to truncate the nth document.

注解

captrunc is an internal command that is not enabled by default. captrunc must be enabled by using --setParameter enableTestCommands=1 on the mongod command line. captrunc cannot be enabled during run-time.

Examples

The following command truncates 10 older documents from the collection records:

db.runCommand({captrunc: "records" , n: 10})

The following command truncates 100 documents and the 101st document:

db.runCommand({captrunc: "records", n: 100, inc: true})