Simplify database stuff
This commit is contained in:
parent
2747184924
commit
64eaee9a25
1 changed files with 3 additions and 5 deletions
|
|
@ -27,7 +27,6 @@ import java.lang.reflect.Field;
|
||||||
|
|
||||||
public class Mongo {
|
public class Mongo {
|
||||||
|
|
||||||
MongoClient client;
|
|
||||||
MongoDatabase db;
|
MongoDatabase db;
|
||||||
Config config;
|
Config config;
|
||||||
|
|
||||||
|
|
@ -36,8 +35,7 @@ public class Mongo {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void connect() {
|
public void connect() {
|
||||||
client = MongoClients.create("mongodb://" + config.getDatabaseUsername() + ":" + config.getDatabasePassword() + "@" + config.getDatabaseIP() + ":" + config.getDatabasePort() + "/?authSource=admin");
|
db = MongoClients.create("mongodb://" + config.getDatabaseUsername() + ":" + config.getDatabasePassword() + "@" + config.getDatabaseIP() + ":" + config.getDatabasePort() + "/?authSource=admin").getDatabase("Hadder");
|
||||||
db = client.getDatabase("Hadder");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getByID(String collection_name, String where, String what, String column) {
|
public Object getByID(String collection_name, String where, String what, String column) {
|
||||||
|
|
@ -69,11 +67,11 @@ public class Mongo {
|
||||||
public void remove(String table, String where, String value) {
|
public void remove(String table, String where, String value) {
|
||||||
BasicDBObject whereQuery = new BasicDBObject();
|
BasicDBObject whereQuery = new BasicDBObject();
|
||||||
whereQuery.put(where, value);
|
whereQuery.put(where, value);
|
||||||
client.getDatabase("VoiceAnalyzer").getCollection(table).deleteOne(whereQuery);
|
db.getCollection(table).deleteOne(whereQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void insert(String table, Document doc) {
|
public void insert(String table, Document doc) {
|
||||||
client.getDatabase("VoiceAnalyzer").getCollection(table).insertOne(doc);
|
db.getCollection(table).insertOne(doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void insertUser(String id) {
|
public void insertUser(String id) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue