private DBObject translateArrayElemMatch(FieldTreeNode context, ArrayMatchExpression expr) { FieldTreeNode arrayNode = resolve(context, expr.getArray()); if (arrayNode instanceof ArrayField) { ArrayElement el = ((ArrayField) arrayNode).getElement(); if (el instanceof ObjectArrayElement) { return new BasicDBObject(translatePath(expr.getArray()), new BasicDBObject("$elemMatch", translate(el, expr.getElemMatch()))); } } throw Error.get(ERR_INVALID_FIELD, expr.toString()); }
private DBObject translateArrayElemMatch(FieldTreeNode context, EntityMetadata md, ArrayMatchExpression expr, EntityMetadata emd, MutablePath fullPath) { FieldInfo finfo=resolveFieldForQuery(context,fullPath.immutableCopy(),expr.getArray()); if (finfo.fieldMd instanceof ArrayField) { ArrayElement el = ((ArrayField) finfo.fieldMd).getElement(); if (el instanceof ObjectArrayElement) { fullPath.push(finfo.field).push(Path.ANYPATH); BasicDBObject obj = new BasicDBObject(translatePath(finfo.field), new BasicDBObject("$elemMatch", translate(el, expr.getElemMatch(), emd, fullPath))); fullPath.pop().pop(); return obj; } else { throw new NeedsJS(); } } throw Error.get(ERR_INVALID_FIELD, expr.toString()); }