How to present the results of the aggregation as an array of strings (values) and not as a BSON object with a key and and a value?

The function aggregate return a cursor, not an object.

Something like the following should work:

/* Store all the documents from the results cursor */
all_results = results.toArray()
/* Get the first document */
first_result = all_results[0]
/* Get the array of strings */
array = first_result.duplicatedDataSourceIds

Please read Formatting code and log snippets in posts before next post so that we can cut-n-paste your code.

I hope you are safe.

1 Like