Database Manual / Reference / Database Commands / Administration

compactStructuredEncryptionData (database command数据库命令)

Definition定义

compactStructuredEncryptionData
Compacts documents specified in the metadata collections and deletes redundant documents.压缩元数据集合中指定的文档并删除冗余文档。

Compatibility兼容性

This command is available in deployments hosted in the following environments:此命令在以下环境中托管的部署中可用:

  • MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud:云中MongoDB部署的完全托管服务

Note

This command is supported in all MongoDB Atlas clusters. 所有MongoDB Atlas集群都支持此命令。For information on Atlas support for all commands, see Unsupported Commands.有关Atlas支持所有命令的信息,请参阅不支持的命令

  • MongoDB Enterprise: The subscription-based, self-managed version of MongoDB:MongoDB的基于订阅的自我管理版本
  • MongoDB Community: The source-available, free-to-use, and self-managed version of MongoDB:MongoDB的源代码可用、免费使用和自我管理版本

Syntax语法

The command has the following syntax:该命令具有以下语法:

db.runCommand(
{
compactStructuredEncryptionData: <collection>,
compactionTokens: {
encryptedFieldPath: bindata,
...
},
}
)

Command Fields命令字段

The command takes the following fields:该命令包含以下字段:

Field字段Type类型Description描述
compactStructuredEncryptionDatastring字符串The name of the collection.集合的名称。
compactionTokensdocument文档A document that maps index fields to compaction tokens.将索引字段映射到压缩标记的文档。

The mongosh provides a wrapper method db.collection.compactStructuredEncryptionData().mongosh提供了一个包装器方法db.collection.compactStructuredEncryptionData()

Required Access所需访问权限

The built-in roles readWriteAnyDatabase and dbOwner provide compactStructuredEncryptionData actions on resources.内置角色readWriteAnyDatabasedbOwner在资源上提供compactStructuredEncryptionData操作。

Example示例

See metadata collection compaction for an example.有关示例,请参阅元数据集合压缩