接口定义
truncateCollections() 用于清空 Base 类数据库的 Collection 中所有的数据与索引,仅保留 Collection 配置信息,例如索引类型及参数、分片等设置,减少用户的操作成本。
public AffectRes truncateCollections(String collectionName)
接口约束
警告:
执行 truncate 操作将会永久删除指定 Collection 下的所有数据。在操作之前,务必谨慎考虑。
使用示例
// link databaseDatabase db = client.database("db-test");// truncateAffectRes affectRes = db.truncateCollections("book-vector");System.out.println("\\tres: " + affectRes);
入参描述
参数名 | 是否必选 | 参数含义 | 配置方法 |
collectionName | 是 | 所需删除的 Collection 名称。 | Collection 命名要求如下: 只能使用英文字母,数字,下划线_、中划线-,并以英文字母开头。 长度要求:[1,128]。 |
出参描述
res: AffectRes{affectedCount=1, code=0, msg='operation success'}
参数名 | 参数含义 |
affectedCount | 影响行数,即为清空数据的集合数量。 |