Hello !

I'm trying to write a function that accepts a mongodb collection cursor as parameter but I do not know how to do that as cursor is a template type.

Can anyone give some help on this ?

protected void sendCollectionListAsDataArrayJson2(??????auto??????? collection_list, HTTPServerResponse res, in string[] fields)
{

if(!collection_list.empty)
{
	auto buf = appender!string();
	buf.put("{\"data\":[\n");
	int count = 0;
	foreach(doc; result)
	{
		if(count++ > 0)
		{
			buf.put(",");
		}
		
		buf.put("[");
		
		int count2 = 0;
		foreach( string fld; fields )
		{
			Bson v = doc[fld];
			if(count2++ > 0)
			{
				buf.put(",");
			}
			buf.put(v.toJson().toString());
		}
		
		buf.put("]\n");
	}
	buf.put("]}\n");
	res.writeBody(buf.data, "application/json");
}

}

protected void sendCollectionListAsDataArrayJson(MongoClient mongodb, HTTPServerResponse res,

const string collection_name, int limit, in string[] fields)

{

auto result = getCollectionList(mongodb, res, collection_name, limit);
sendCollectionListAsDataArrayJson2(result, res, fields);

}

Cheers !