All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.anwen.mongo.annotation.index.MongoIndex Maven / Gradle / Ivy

There is a newer version: 2.1.5
Show newest version
package com.anwen.mongo.annotation.index;

import com.anwen.mongo.enums.IndexDirection;

import java.lang.annotation.*;

/**
 * 注解式索引自动创建
 * @author anwen
 */
@Target({ElementType.ANNOTATION_TYPE,ElementType.FIELD})
//运行时注解
@Retention(RetentionPolicy.RUNTIME)
//表明这个注解应该被 javadoc工具记录
//生成文档
@Documented
public @interface MongoIndex {

    /**
     * 索引名称
     * @author anwen
     * @date 2024/8/18 13:25
     */
    String name() default "";

    /**
     * 唯一索引
     * @author anwen
     * @date 2024/8/18 13:26
     */
    boolean unique() default false;

    /**
     * 索引排序方向
     * @author anwen
     * @date 2024/8/18 13:32
     */
    IndexDirection direction() default IndexDirection.ASC;

    /**
     * 稀疏索引
     * @author anwen
     * @date 2024/8/18 13:33
     */
    boolean sparse() default false;

    /**
     * 索引过期时间,以秒为单位
     * @author anwen
     * @date 2024/8/18 13:34
     */
    long expireAfterSeconds() default -1;

    /**
     * 自定义类型的索引过期时间
     * 
    *
  • d: 天
  • *
  • h: 时
  • *
  • m: 分
  • *
  • s: 秒
  • *
*

{@code @MongoIndex(expireAfter = "1d")}

*

{@code @MongoIndex(expireAfter = "3h")}

*

{@code @MongoIndex(expireAfter = "30m")}

*

{@code @MongoIndex(expireAfter = "30s")}

* @author anwen * @date 2024/8/18 13:34 */ String expireAfter() default ""; /** * 部分索引 *

例:{"$gt",5}

* @author anwen * @date 2024/8/18 15:17 */ String partialFilterExpression() default ""; /** * 是否应该在后台创建索引 * @author anwen * @date 2024/8/18 20:59 */ boolean background() default false; }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy