I am trying to find a way to get a collection
from mongohq
using Java and rest API.
I know that I can get the collection on by one using Java:
public static String get(String collection, String id)
{
return getString = getFromMongo("https://api.mongohq.com/databases/db/collections/"+collection+"/documents/"+id+"?_apikey=XXXXXXXXXXXX");
}
public static String getFromMongo(String url)
{
try
{
InputStream is = new URL(url).openStream();
BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
StringBuilder sb = new StringBuilder();
int cp;
while ((cp = rd.read()) != -1)
sb.append((char) cp);
return sb.toString();
}
catch(Exception e)
{
System.out.println("getFromMongo: "+ e);
return null;
}
}
But I want to write a function that returns a Set<String>
of all the documents in current collection. Anyone can help me?
I didn't find a query that does it in the rest api documentation...
Thanks