Document is workhorse of Mongo 3.x API
While Document is the default for MongoCollection, the interface is generic and allows an application to use any type that is required, so long as there is a Codec registered for it, e.g.
MongoDatabase database = client.getDatabase("test").withCodecRegistry(...); MongoCollection<Tuple> collection = database.getCollection("tuples", Tuple.class);
Tuple someTuple = ...
collection.insertOne(someTuple);
Tuple t = collection.find().first();
I don't think it would be particularly difficult to write an efficient class that implements Codec<Tuple>, though I'm not familiar with the Tuple API. Is it this? |