import lombok.Data;import org.springframework.data.mongodb.core.index.CompoundIndex;import org.springframework.data.mongodb.core.index.CompoundIndexes;import org.springframework.data.mongodb.core.mapping.Document;import java.util.Date;/** * @Describe: 用户活跃日志 * @Date: 2019/1/8 14:14 */@Document(collection = "user_active_log")@CompoundIndexes({ //name:索引名称 def:字段(1正序 -1倒序) unique:是否唯一索引 //直接加到字段上面没用 @CompoundIndex(name = "uq_userno_date", def = "{userNo:1, date:-1}", unique = true)})@Datapublic class UserActiveLog { private String id; private String userNo; private String date;//yyyyMMdd格式的日期 private Date created;}
查看效果