query.setStartKey(schemaName); query.setEndKey(schemaName); query.setIncludeDocs(true);
static public DocumentRetrieval create(CouchDb couchDb, String schemaName) throws Exception { CouchDesignDocument dd = couchDb.getDesignDocument("atlas"); CouchQuery query = new CouchQuery(); query.setViewName("nunaliit-schema"); query.setStartKey(schemaName); query.setEndKey(schemaName); query.setIncludeDocs(false); CouchQueryResults results = dd.performQuery(query); Set<String> ids = new HashSet<String>(); for(JSONObject row : results.getRows()){ String docId = row.optString("id"); if( null != docId ) { ids.add(docId); } } return new DocumentRetrievalSchema(couchDb, ids.iterator()); }
static public DocumentRetrieval create(CouchDb couchDb, String layerName) throws Exception { CouchDesignDocument dd = couchDb.getDesignDocument("atlas"); CouchQuery query = new CouchQuery(); query.setViewName("geom-layer"); query.setStartKey(layerName); query.setEndKey(layerName); query.setIncludeDocs(false); CouchQueryResults results = dd.performQuery(query); Set<String> ids = new HashSet<String>(); for(JSONObject row : results.getRows()){ String docId = row.optString("id"); if( null != docId ) { ids.add(docId); } } return new DocumentRetrievalLayer(couchDb, ids.iterator()); }
@Override public JSONObject getUserFromEmailAddress(String emailAddress) throws Exception { try { CouchQuery query = new CouchQuery(); query.setViewName("validated-emails"); query.setStartKey(emailAddress); query.setEndKey(emailAddress); query.setIncludeDocs(true); CouchQueryResults results = nunaliitUserDesignDocument.performQuery(query); List<JSONObject> rows = results.getRows(); for(JSONObject row : rows){ JSONObject doc = row.optJSONObject("doc"); if( null != doc ){ return doc; } } throw new Exception("Unable to find user with e-mail address: "+emailAddress); } catch (Exception e) { throw new Exception("Error while searching user with e-mail address: "+emailAddress,e); } }
query.setStartKey(agreementRole); query.setEndKey(agreementRole);