Domanda

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...

È stato utile?

Soluzione

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

var parameters = BSONArray()
parameters = parameters add BSONDocument("$limit" -> limit)
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top