我将 Mongo DBRef与 Java 驱动程序一起使用,但 Mongo 客户端返回 DBRef 对象而不是 Map 对象。
Document doc = new Document();
doc.append("projectName", "New project");
doc.append("owner", new DBRef("users", owner.get_id()));
client.getDatabase("db").getCollection("projects").insertOne(doc);
然后我读了集合
MongoCollection<Document> coll = client.getDatabase("db").getCollection("projects");
FindIterable<Document> result = coll.find(query);
BasicDBList list = new BasicDBList();
result.into(list);
return list;
谢谢您的帮助