Monger's DBRef cannot work with com.mongodb.DBRef without fundamental re-thinking
com.mongodb.DBRef#fetch was removed.
This commit is contained in:
parent
2128f2cd6c
commit
d9e6be671a
2 changed files with 3 additions and 47 deletions
|
|
@ -82,8 +82,8 @@
|
||||||
DBObject
|
DBObject
|
||||||
(to-db-object [^DBObject input] input)
|
(to-db-object [^DBObject input] input)
|
||||||
|
|
||||||
com.novemberain.monger.DBRef
|
com.mongodb.DBRef
|
||||||
(to-db-object [^com.novemberain.monger.DBRef dbref]
|
(to-db-object [^com.mongodb.DBRef dbref]
|
||||||
dbref)
|
dbref)
|
||||||
|
|
||||||
Object
|
Object
|
||||||
|
|
@ -118,7 +118,7 @@
|
||||||
|
|
||||||
com.mongodb.DBRef
|
com.mongodb.DBRef
|
||||||
(from-db-object [^com.mongodb.DBRef input keywordize]
|
(from-db-object [^com.mongodb.DBRef input keywordize]
|
||||||
(com.novemberain.monger.DBRef. input))
|
input)
|
||||||
|
|
||||||
DBObject
|
DBObject
|
||||||
(from-db-object [^DBObject input keywordize]
|
(from-db-object [^DBObject input keywordize]
|
||||||
|
|
|
||||||
|
|
@ -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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in a new issue