The following collection contains the ticks for the diverse exchange symbols (in this case BTCUSD and BTCEUR):
{ "_id" : ObjectId("5a08d2b956df9b2302759d1a"), "symbol" : "BTCUSD", "time" : ISODate("2013-04-13T00:00:00Z"), "open" : 112, "close" : 91.1, "high" : 130, "low" : 81.12, "volume" : 23866.6770456 }
{ "_id" : ObjectId("5a08d2b956df9b2302759d1c"), "symbol" : "BTCUSD", "time" : ISODate("2013-04-14T00:00:00Z"), "open" : 91.1, "close" : 90.171, "high" : 109, "low" : 20, "volume" : 16437.2196645 }
{ "_id" : ObjectId("5a08d2b956df9b2302759d1e"), "symbol" : "BTCEUR", "time" : ISODate("2013-04-15T00:00:00Z"), "open" : 89.86, "close" : 83.302, "high" : 104, "low" : 71.497, "volume" : 16393.12856398 }
{ "_id" : ObjectId("5a08d2b956df9b2302759d20"), "symbol" : "BTCEUR", "time" : ISODate("2013-04-16T00:00:00Z"), "open" : 84.27, "close" : 67.588, "high" : 84.48, "low" : 0.01, "volume" : 26092.5432296 }
How do I get the list of symbols actually present in the collection in Go? For instance, the result I'm looking for is:
{ "BTCUSD", "BTCEUR" }
This would let me retrieve the latest tick values from the exchange service without having to store somewhere the symbols I'm interested in.
From the mongo shell I've tried this...
db.candles.aggregate({$group: {_id:"$symbol"}})
... and here is the result:
{ "_id" : "BTCUSD" }
{ "_id" : "BTCEUR" }
What is the equivalent in Go using mgo? Is it possible to just get an array of symbols instead of a collection of "_id" : "value" pairs?