InsertOne/InsertMany/ReplaceOne do not accept a BsonValue parameter like updateOne/updateMany does.

XMLWordPrintableJSON

    • Type: New Feature
    • Resolution: Won't Fix
    • Priority: Minor - P4
    • None
    • Affects Version/s: 3.6.3
    • Component/s: API
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      We started implementing the ORM that came with version 3.x.

      We decorate our Pojos with a custom hash. We now use your ORM to convert the object to BsonDocuments, we then edit it, and then we use it with your MongoCollection.

      I've got it all to work, but i'm disappointed that some methods do not accept 'raw' bson as a parameter (eg: insertOne and replaceOne).

      I've got 2 work-a-rounds for this:

      • Emulate these methods around with updateOne.
      • Generic the MongoCollection to BsonDocument instead.

      I much prefer if MongoCollection supports these method with Bson as a value, as update does.

      For your reference, what I suggest is adding:

      • MongoCollection<D>.insertOne(Bson document)
      • MongoCollection<D>.replaceOne(Bson filter, Bson replacement)
        etc.
        Similar to updateOne(Bson filter, Bson update).

      Looking through the code of MongoCollectionImpl, it seems internally the Pojo is rather quickly converted to Bson.

            Assignee:
            Jeffrey Yemin
            Reporter:
            Jesse van Houten
            None
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: