I have a collection which stores values as arrays, but these need to be strings.
Out of 4000 data sets 800 look like this
{'_id': '5c4f8408fc69ca02c92ac822',
'enabled': true,
'order_date': '2019-01-29T10:36:56.906Z',
'order_id': 'PO-ERSNJ9',
'productId': ['5dd5ca0170ebec13b8ab1134'],
'selling_date': null,
'selling_price': 99.99,
'split_invoice': null}
for these 800 I need to convert
"productId" : [ "5dd5ca0170ebec13b8ab1134" ]
into
"productId" : "5dd5ca0170ebec13b8ab1134"
via mongo shell.
I already figured, that reduce (aggregation) would be the way to go,
but I cannot get the syntax right.
Help would be great. Thanks a lot