package kz.konturai.parser.config;

import kz.konturai.parser.model.FacebookLead;
import org.springframework.boot.ApplicationRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.index.Index;

@Configuration
public class FacebookLeadMongoConfig {

    @Bean
    public ApplicationRunner facebookLeadIndexesRunner(MongoTemplate mongoTemplate) {
        return args -> mongoTemplate.indexOps(FacebookLead.class)
                .ensureIndex(new Index().on("external_comment_id", Sort.Direction.ASC).unique());
    }
}
