forked from Fascinated/Bat
big ass refactor to handle loading guilds and users without spring to make it more futureproof
This commit is contained in:
40
src/main/java/cc/fascinated/bat/service/MongoService.java
Normal file
40
src/main/java/cc/fascinated/bat/service/MongoService.java
Normal file
@ -0,0 +1,40 @@
|
||||
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;
|
||||
private final MongoTemplate mongo;
|
||||
|
||||
@Autowired
|
||||
public MongoService(MongoTemplate mongo) {
|
||||
INSTANCE = this;
|
||||
this.mongo = mongo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the guilds collection
|
||||
*
|
||||
* @return The guilds collection
|
||||
*/
|
||||
public MongoCollection<Document> getGuildsCollection() {
|
||||
return mongo.getCollection("guilds");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the users collection
|
||||
*
|
||||
* @return The users collection
|
||||
*/
|
||||
public MongoCollection<Document> getUsersCollection() {
|
||||
return mongo.getCollection("users");
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user