mongodb创建集合的时候,指定索引
IndexOptions indexOptions=new IndexOptions(); //后台创建索引 indexOptions.background(true); //唯一索引 indexOptions.unique(true); //如果为true,则索引仅引用具有指定字段的文档 // indexOptions.sparse(true); mongoTemplate.createCollection(collectionName).createIndex(Indexes.ascending("planId"),indexOptions);
一点点学习,一丝丝进步。不懈怠,才不会被时代淘汰