package com.hepl.tunefortwo.config.db;

import java.util.Locale;

import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.index.Index;
import org.springframework.data.mongodb.core.query.Collation;

import com.hepl.tunefortwo.entity.Users;

import jakarta.annotation.PostConstruct;

@Configuration
@DependsOn("mongoTemplate")
public class Indexing {

        private final MongoTemplate mongoTemplate;

        public Indexing(MongoTemplate mongoTemplate) {
                this.mongoTemplate = mongoTemplate;
        }

        // @PostConstruct
        // void ensureIndexes() {

        //         // Collation for checking case-insensitive data
        //         mongoTemplate.indexOps(Users.class).ensureIndex(
        //                         new Index("userId", Sort.Direction.ASC).unique()
        //                                         .collation(Collation.of(Locale.US).strength(2)));

        //         mongoTemplate.indexOps(Users.class).ensureIndex(
        //                         new Index("username", Sort.Direction.ASC).unique()
        //                                         .collation(Collation.of(Locale.US).strength(2)));

        //         mongoTemplate.indexOps(Users.class).ensureIndex(
        //                         new Index("email", Sort.Direction.ASC).unique()
        //                                         .collation(Collation.of(Locale.US).strength(2)));

        //         mongoTemplate.indexOps(Users.class).ensureIndex(
        //                         new Index("mobile", Sort.Direction.ASC).unique()
        //                                         .collation(Collation.of(Locale.US).strength(2)));

        // }

}
