Java -MongoDB Add DBRef

摘要:Java -MongoDB Add DBRef

            mongo = this.dao.getMongo();//取的Mongo物件,自行撰寫
            db = this.dao.getDB(mongo);//取得DB物件,自行撰寫
            DBCollection collection = db.getCollection(this.collection_name);
            obj.append("ref_field",new DBRef(db,"ref_collection_name",obj.getString("ref_field_id"))); 
            collection.save(obj)