0

I'm getting an 'error validating settings: query is not valid JSON: json: cannot unmarshal string into Go value of type map[string]interface {}' when trying to output my query to CSV.

My query is: 'dev_experts:{$aggregate([{$unwind:"$expertise"}])}'

How do I "unmarshal" that? I've run the query through Robomongo and I can see the results I want to export, but I can't export them through there.

Thanks in advance.

Community
  • 1
  • 1
James Heslip
  • 11
  • 1
  • 3

1 Answers1

0

Maybe you should try this query syntax, though I'm not an Robomongo expert ;)

db.dev_experts.aggregate([{$unwind:"$expertise"}]);

cf https://docs.mongodb.com/manual/reference/operator/aggregation/unwind/ for more infos.

  • That works fine in Robomongo for a query, as in I can view the result of it, but I'm then looking to export the result of that to a CSV. – James Heslip Aug 15 '17 at 10:25
  • Use mongoexport in a terminal, type : `mongoexport --username x --password x --host x --db mydb --collection dev_experts --query '{dev_experts:{$aggregate([{$unwind:"$expertise"}])}' --type=csv --fields id,expertise --out "./myfile.csv"` – Pierre H. Gallet Aug 15 '17 at 13:12
  • 1
    Still reports that it cannot unmarshal string into Go value type of map[string]interface {} – James Heslip Aug 15 '17 at 13:21