code: protected void putDBRef(final String name, final DBRef ref) {
          BasicDBObject dbRefDocument = new BasicDBObject("$ref", ref.getCollectionName()).append("$id", ref.getId());
          if (ref.getDatabaseName() != null) {
              dbRefDocument.put("$db", ref.getDatabaseName());
          }
  
          putObject(name, dbRefDocument);
      }
docs: Deals with encoding database references.
  
  @param name the name of the field in the document
  @param ref  the database reference object