package com.novelreader.model; import lombok.Data; import org.springframework.data.annotation.Id; 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.time.Instant; @Data @Document(collection = "history") @CompoundIndexes({ @CompoundIndex(name = "userId_novelId_unique", def = "{'userId': 1, 'novelId': 1}", unique = true) }) public class History { @Id private String id; private String userId; private String novelId; private String chapterId; private Integer position; private Instant lastReadAt; }