package be.naaturel.boardmateapi.configurations.configurations;

import be.naaturel.boardmateapi.configurations.properties.AppProperties;
import com.mongodb.client.MongoClient;
import com.mongodb.client.MongoClients;
import org.springframework.data.mongodb.core.MongoTemplate;

public class MongoConfig {

    private final AppProperties conf;

    public MongoConfig(AppProperties appConf) {
        this.conf = appConf;
    }

    public MongoTemplate mongoTemplate() {
        System.out.println(">>> Connection string : " + conf.connectionString);
        System.out.println(">>> Used database : " + conf.database);
        MongoClient client = MongoClients.create(this.conf.connectionString);
        return new MongoTemplate(client, conf.database);
    }
}