Monger's DBRef cannot work with com.mongodb.DBRef without fundamental re-thinking

com.mongodb.DBRef#fetch was removed.
This commit is contained in:
Michael Klishin 2015-02-22 19:24:10 +03:00
parent 2128f2cd6c
commit d9e6be671a
2 changed files with 3 additions and 47 deletions

View file

@ -82,8 +82,8 @@
DBObject
(to-db-object [^DBObject input] input)
com.novemberain.monger.DBRef
(to-db-object [^com.novemberain.monger.DBRef dbref]
com.mongodb.DBRef
(to-db-object [^com.mongodb.DBRef dbref]
dbref)
Object
@ -118,7 +118,7 @@
com.mongodb.DBRef
(from-db-object [^com.mongodb.DBRef input keywordize]
(com.novemberain.monger.DBRef. input))
input)
DBObject
(from-db-object [^DBObject input keywordize]

View file

@ -1,44 +0,0 @@
package com.novemberain.monger;
import clojure.lang.IDeref;
import com.mongodb.DB;
import com.mongodb.DBObject;
import org.bson.BSONObject;
/**
* Exactly as com.mongodb.DBRef but also implements Clojure IDeref for @dereferencing
*/
public class DBRef extends com.mongodb.DBRef implements IDeref {
/**
* Creates a DBRef
* @param db the database
* @param o a BSON object representing the reference
*/
public DBRef(DB db, BSONObject o) {
super(db , o.get("$ref").toString(), o.get("$id"));
}
/**
* Creates a DBRef
* @param db the database
* @param ns the namespace where the object is stored
* @param id the object id
*/
public DBRef(DB db, String ns, Object id) {
super(db, ns, id);
}
/**
* Creates a DBRef from a com.mongodb.DBRef instance.
* @param source The original reference MongoDB Java driver uses
*/
public DBRef(com.mongodb.DBRef source) {
this(source.getDB(), source.getRef(), source.getId());
}
@Override
public DBObject deref() {
return this.fetch();
}
}