The variable valueId is the result of aggregate() which is a cursor.

If you are absolutely sure you get a single document from your aggregation you may use

    valueId.toArray[0].idString

to get the value you want.

However, I think it is best to iterate the cursor. See