@Override protected DBCollection getCollection(Class<?> type) { return datastore.getCollection(type); }
public MorphiaQuery(final Morphia morphia, final Datastore datastore, final EntityCache cache, final Class<? extends K> entityType) { super(datastore.getCollection(entityType), new Function<DBObject, K>() { @Override public K apply(DBObject dbObject) { return morphia.fromDBObject(datastore, entityType, dbObject, cache); } }, new MorphiaSerializer(morphia)); this.datastore = datastore; this.cache = cache; }
@Override protected DBCollection getCollection(Class<?> type) { return datastore.getCollection(type); }
public MorphiaQuery(final Morphia morphia, final Datastore datastore, final EntityCache cache, final Class<? extends K> entityType) { super(datastore.getCollection(entityType), new Function<DBObject, K>() { @Override public K apply(DBObject dbObject) { return morphia.fromDBObject(entityType, dbObject, cache); } }, new MorphiaSerializer(morphia)); this.datastore = datastore; this.cache = cache; }
public DBCollection col() { return ds().getCollection(c_); }
public DBCollection col() { return ds().getCollection(c_); }
public static void delete(Class ... types) { idCache.clear(); for (Class<? extends Model> type: types) { ds().getCollection(type).drop(); } }
public static void delete(List<Class<? extends play.db.Model>> classes) { idCache.clear(); for (Class<? extends play.db.Model> type: classes) { ds().getCollection(type).drop(); } }
@Nonnull @Override public Optional<UserId> getUserIdForApiKey(@Nonnull HashedApiKey apiKey) { DBCollection collection = datastore.getCollection(UserApiKeys.class); DBObject query = object(API_KEYS__API_KEY, apiKey.get()); DBObject projection = object(USER_ID, INCLUDE); DBObject found = collection.findOne(query, projection); return Optional.ofNullable(found) .map(object -> object.get(USER_ID).toString()) .map(UserId::getUserId); } }
public static void deleteDatabase() { idCache.clear(); Datastore ds = ds(); for (Class<Model> clz: Play.classloader.getAssignableClasses(Model.class)) { ds.getCollection(clz).drop(); } }
public DBCollection collection() { return ds().getCollection(modelType()); }
public static <T extends Model> WriteResult insert(List<T> entities) { if (entities.isEmpty()) return null; T t = entities.get(0); List<DBObject> l = new ArrayList<DBObject>(entities.size()); Morphia morphia = MorphiaPlugin.morphia(); boolean populateId = !MorphiaPlugin.getIdType().isObjectId(); for (T entity: entities) { if (populateId) entity.setId(IdGenerator.generateId(entity)); l.add(morphia.toDBObject(entity)); } return t.ds().getCollection(t.getClass()).insert(l); }
/** * * @param groupKeys * could be either "f1Andf2.." or "f1 f2" or "f1,f2" * @return */ public List<BasicDBObject> group(String groupKeys, DBObject initial, String reduce, String finalize) { DBObject key = new BasicDBObject(); if (!S.empty(groupKeys)) { if (groupKeys.startsWith("by")) groupKeys = groupKeys.substring(2); String[] sa = groupKeys.split("(And|[\\s,;]+)"); for (String s : sa) { key.put(MorphiaPlugin.mongoColName(c_, s), true); } } return (List<BasicDBObject>) ds().getCollection(c_).group(key, q_.getQueryObject(), initial, reduce, finalize); }
private List<BasicDBObject> group(String groupKeys, DBObject initial, String reduce, String finalize) { DBObject key = new BasicDBObject(); if (!S.empty(groupKeys)) { String[] sa = MorphiaService.splitGroupKeys(groupKeys); for (String s : sa) { key.put(s, true); } } return (List<BasicDBObject>) ds.getCollection(modelType).group(key, mq.getQueryObject(), initial, reduce, finalize); }
@Override public void dropApiKey(@Nonnull UserId userId, @Nonnull ApiKeyId apiKeyId) { DBCollection collection = datastore.getCollection(UserApiKeys.class); DBObject ops = object("$pull", // From object(API_KEYS, // where object(API_KEY_ID, apiKeyId.getId()))); // Match the UserId DBObject query = object(USER_ID, userId.getUserName()); collection.update(query, ops); }
collection = datastore.getCollection(key.getType()); id = ref; } else {