/** * Add a constraint to the query that requires a particular key's value matches a value for a key * in the results of another AVQuery * * @param key The key whose value is being checked * @param keyInQuery The key in the objects from the sub query to look in * @param query The sub query to run * @return Returns the query so you can chain this call. */ public AVQuery<T> whereMatchesKeyInQuery(String key, String keyInQuery, AVQuery<?> query) { Map<String, Object> inner = new HashMap<String, Object>(); inner.put("className", query.getClassName()); inner.put("where", query.conditions.compileWhereOperationMap()); if (query.conditions.getSkip() > 0) inner.put("skip", query.conditions.getSkip()); if (query.conditions.getLimit() > 0) inner.put("limit", query.conditions.getLimit()); if (!AVUtils.isBlankContent(query.getOrder())) inner.put("order", query.getOrder()); Map<String, Object> queryMap = new HashMap<String, Object>(); queryMap.put("query", inner); queryMap.put("key", keyInQuery); return addWhereItem(key, "$select", queryMap); }
/** * Add a constraint to the query that requires a particular key's value matches a value for a key * in the results of another AVQuery * * @param key The key whose value is being checked * @param keyInQuery The key in the objects from the sub query to look in * @param query The sub query to run * @return Returns the query so you can chain this call. */ public AVQuery<T> whereMatchesKeyInQuery(String key, String keyInQuery, AVQuery<?> query) { Map<String, Object> inner = new HashMap<String, Object>(); inner.put("className", query.getClassName()); inner.put("where", query.conditions.compileWhereOperationMap()); if (query.conditions.getSkip() > 0) inner.put("skip", query.conditions.getSkip()); if (query.conditions.getLimit() > 0) inner.put("limit", query.conditions.getLimit()); if (!AVUtils.isBlankContent(query.getOrder())) inner.put("order", query.getOrder()); Map<String, Object> queryMap = new HashMap<String, Object>(); queryMap.put("query", inner); queryMap.put("key", keyInQuery); return addWhereItem(key, "$select", queryMap); }
Map<String, Object> myQueryParameters(AVQuery query) { Map<String, Object> parameters = new HashMap<String, Object>(); if (query.getWhere().keySet().size() > 0) { parameters.put("where", AVUtils.getParsedMap(query.getWhere())); } if (query.getLimit() > 0) { parameters.put("limit", Integer.toString(query.getLimit())); } if (query.getSkip() > 0) { parameters.put("skip", Integer.toString(query.getSkip())); } if (query.getOrder() != null && query.getOrder().length() > 0) { parameters.put("order", query.getOrder()); } if (query.getInclude() != null && query.getInclude().size() > 0) { String value = AVUtils.joinCollection(query.getInclude(), ","); parameters.put("include", value); } if (query.getSelectedKeys() != null && query.getSelectedKeys().size() > 0) { String keys = AVUtils.joinCollection(query.getSelectedKeys(), ","); parameters.put("keys", keys); } return parameters; }
/** * Add a constraint to the query that requires a particular key's value match another AVQuery. * This only works on keys whose values are AVObjects or lists of AVObjects. * * @param key The key to check. * @param query The query that the value should match * @return Returns the query so you can chain this call. */ public AVQuery<T> whereMatchesQuery(String key, AVQuery<?> query) { Map<String, Object> map = AVUtils.createMap("where", query.conditions.compileWhereOperationMap()); map.put("className", query.className); if (query.conditions.getSkip() > 0) map.put("skip", query.conditions.getSkip()); if (query.conditions.getLimit() > 0) map.put("limit", query.conditions.getLimit()); if (!AVUtils.isBlankContent(query.getOrder())) map.put("order", query.getOrder()); addWhereItem(key, "$inQuery", map); return this; }
Map<String, Object> myQueryParameters(AVQuery query) { Map<String, Object> parameters = new HashMap<String, Object>(); if (query.getWhere().keySet().size() > 0) { parameters.put("where", AVUtils.getParsedMap(query.getWhere())); } if (query.getLimit() > 0) { parameters.put("limit", Integer.toString(query.getLimit())); } if (query.getSkip() > 0) { parameters.put("skip", Integer.toString(query.getSkip())); } if (query.getOrder() != null && query.getOrder().length() > 0) { parameters.put("order", query.getOrder()); } if (query.getInclude() != null && query.getInclude().size() > 0) { String value = AVUtils.joinCollection(query.getInclude(), ","); parameters.put("include", value); } if (query.getSelectedKeys() != null && query.getSelectedKeys().size() > 0) { String keys = AVUtils.joinCollection(query.getSelectedKeys(), ","); parameters.put("keys", keys); } return parameters; }
/** * Add a constraint to the query that requires a particular key's value match another AVQuery. * This only works on keys whose values are AVObjects or lists of AVObjects. * * @param key The key to check. * @param query The query that the value should match * @return Returns the query so you can chain this call. */ public AVQuery<T> whereMatchesQuery(String key, AVQuery<?> query) { Map<String, Object> map = AVUtils.createMap("where", query.conditions.compileWhereOperationMap()); map.put("className", query.className); if (query.conditions.getSkip() > 0) map.put("skip", query.conditions.getSkip()); if (query.conditions.getLimit() > 0) map.put("limit", query.conditions.getLimit()); if (!AVUtils.isBlankContent(query.getOrder())) map.put("order", query.getOrder()); addWhereItem(key, "$inQuery", map); return this; }