Question

I have initiated an empty BSONArray an the used the add function to add some BSONDocuments but BSONArray stays empty

Here is some sample code

  var parameters = BSONArray()
  parameters add BSONDocument("$limit" -> limit)

The limit document is just not added...

Was it helpful?

Solution

I suspect BSONArray is immutable and the add operation is returning a new array. Try:

var parameters = BSONArray()
parameters = parameters add BSONDocument("$limit" -> limit)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top