下面是我正在使用的代码 -
mongoClient = new MongoClient("localhost", 27017);
MongoDatabase database = mongoClient.getDatabase("sample");
MongoCollection<Document> imagescollaction = database.getCollection("images");
System.out.println("_id value : " + imagescollaction.find().first().get("_id"));
程序输出:_id 值:0.0
从 mongo shell 的图像集合中输出
db.images.find();
{ "_id" : 0, "height" : 480, "width" : 640, "tags" : [ "dogs", "work"
] }
{ "_id" : 1, "height" : 480, "width" : 640, "tags" : [ "cats",
"sunrises", "kittens", "travel", "vacation", "work" ] }
我的问题:从 mongo shell 我可以看到这些值是 Long 或 Integer,但是当我使用 find 方法从 java mongo 驱动程序查询时,它正在打印 Double。有谁知道为什么会这样。
我正在使用的 Mongo 驱动程序:3.0.0