mongodb创建集合的时候,指定索引
IndexOptions indexOptions=new IndexOptions();
//后台创建索引
indexOptions.background(true);
//唯一索引
indexOptions.unique(true);
//如果为true,则索引仅引用具有指定字段的文档
// indexOptions.sparse(true);
mongoTemplate.createCollection(collectionName).createIndex(Indexes.ascending("planId"),indexOptions);
本文来自博客园,作者:余生请多指教ANT,转载请注明原文链接:https://www.cnblogs.com/wangbiaohistory/p/17659011.html

浙公网安备 33010602011771号