use of com.massivecraft.massivecore.xlib.mongodb.DBCollection in project MassiveCore by MassiveCraft.
the class DriverMongo method load.
@Override
public Entry<JsonObject, Long> load(Coll<?> coll, String id) {
DBCollection dbcoll = fixColl(coll);
BasicDBObject raw = (BasicDBObject) dbcoll.findOne(new BasicDBObject(ID_FIELD, id));
return loadRaw(raw);
}
use of com.massivecraft.massivecore.xlib.mongodb.DBCollection in project MassiveCore by MassiveCraft.
the class DriverMongo method containsId.
@Override
public boolean containsId(Coll<?> coll, String id) {
DBCollection dbcoll = fixColl(coll);
DBCursor cursor = dbcoll.find(new BasicDBObject(ID_FIELD, id));
return cursor.count() != 0;
}
use of com.massivecraft.massivecore.xlib.mongodb.DBCollection in project MassiveCore by MassiveCraft.
the class DriverMongo method loadAll.
@Override
public Map<String, Entry<JsonObject, Long>> loadAll(Coll<?> coll) {
// Declare Ret
Map<String, Entry<JsonObject, Long>> ret = null;
// Fix Coll
DBCollection dbcoll = fixColl(coll);
// Find All
DBCursor cursor = dbcoll.find();
try {
// Create Ret
ret = new MassiveMap<>(cursor.count());
// For Each Found
while (cursor.hasNext()) {
BasicDBObject raw = (BasicDBObject) cursor.next();
// Get ID
Object rawId = raw.removeField(ID_FIELD);
if (rawId == null)
continue;
String id = rawId.toString();
// Get Entry
Entry<JsonObject, Long> entry = loadRaw(raw);
// NOTE: The entry can be a failed one with null and 0.
// NOTE: We add it anyways since it's an informative failure.
// NOTE: This is supported by our defined specification.
// Add
ret.put(id, entry);
}
} finally {
cursor.close();
}
// Return Ret
return ret;
}
Aggregations