[JAVA-369] Collection#save should also accept BSONObject (not just DBObject) Created: 03/Jun/11  Updated: 24/Jan/14  Resolved: 24/Jan/14

Status: Closed
Project: Java Driver
Component/s: API
Affects Version/s: 2.6.1
Fix Version/s: None

Type: Improvement Priority: Minor - P4
Reporter: Thilo Planz Assignee: Unassigned
Resolution: Won't Fix Votes: 0
Labels: bson
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

I am working with BasicBSONObject (received from code that does not depend on MongoDB), and would like to save them to the database.

Unfortunately, "save" and friends only accept DBObject, so that I have to copy all the data into a BasicDBObject first.

Is it really necessary to only accept DBObjects? From what I can see, the only difference between the two is that DBObject has an "incomplete" flag, and the API checks it for you and prevents accidental upserts using incomplete objects. Can we accept other types of BSONObject and just treat them as "complete"?



 Comments   
Comment by Jeffrey Yemin [ 24/Jan/14 ]

While this seems like a harmless change, it would break binary compatibility, and we're not going to do that.

In 3.0, we're going to introduce a new collection class that in generic, so you will be able to make it take/return anything, so long as there is a encoder/decoder for it.

Comment by Thilo Planz [ 06/Jun/11 ]

This probably applies even more for the "find" family of methods, where the "incomplete object" flag seems not be relevant.

Generated at Thu Feb 08 08:52:07 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.