Bat/src/main/java/cc/fascinated/bat/service/MongoService.java

41 lines
1003 B
Java
Raw Normal View History

package cc.fascinated.bat.service;
import com.mongodb.client.MongoCollection;
import org.bson.Document;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Service;
/**
* @author Fascinated (fascinated7)
*/
@Service
public class MongoService {
public static MongoService INSTANCE;
2024-07-03 22:04:40 +01:00
private final MongoTemplate mongoTemplate;
@Autowired
public MongoService(MongoTemplate mongo) {
INSTANCE = this;
2024-07-03 22:04:40 +01:00
this.mongoTemplate = mongo;
}
/**
* Get the guilds collection
*
* @return The guilds collection
*/
public MongoCollection<Document> getGuildsCollection() {
2024-07-03 22:04:40 +01:00
return mongoTemplate.getCollection("guilds");
}
/**
* Get the users collection
*
* @return The users collection
*/
public MongoCollection<Document> getUsersCollection() {
2024-07-03 22:04:40 +01:00
return mongoTemplate.getCollection("users");
}
}