Get ids of inserted documents when using rxBulkWrite

36 views
Skip to first unread message

Miguel Soares

unread,
Oct 18, 2017, 6:14:20 AM10/18/17
to vert.x
Hello

I'm using vertx and Mongodb. I wanted to bulkWrite an array of documents and that was easily achievable with:


Observable<MongoClientBulkWriteResult> insertAll = mongoClient.rxBulkWrite("collection", documentsToInsert).toObservable();


My problem now is that i can't get the ids of the documents that i just inserted. I thought this could be achived with:


insertAll.subscribe( records -> {
   
// this returns correctly the number of documents inserted
    logger
.info("There were inserted this amount of records " + records.getInsertedCount());  

   
// this returns empty array []
    logger
.info("Records inserted " + records.getUpserts());
})




I dont understand why records.getUpserts() returns empty array. Shouldn't this method return the list of IDs of the documents inserted?


Documentation says:

"An unmodifiable list of upsert data. Each entry has the index of the request that lead to the upsert, and the generated ID of the upsert."


Maybe I misunderstood something.


Best regards

Miguel Soares

unread,
Nov 1, 2017, 12:58:57 PM11/1/17
to vert.x
bump

Paulo Lopes

unread,
Nov 4, 2017, 12:23:00 PM11/4/17
to vert.x
Does the non rx api return the ids? If it does then I guess you discovered a codegen bug
Reply all
Reply to author
Forward
0 new messages