예제 #1
0
 public Object unpackRef(DBRef ref, Class<?> eleType) {
   MongoEntity en = Mongos.entity(eleType);
   if (field.isLazy()) {
     return en.toObject(new BasicDBObject("_id", ref.getId()));
   } else {
     return en.toObject(ref.fetch());
   }
 }
예제 #2
0
 /**
  * 子类复写:修改 get 后的值,以便设置给 DBObject
  *
  * <p>如果不是严格检查的话, adaptor 如果发现自己不能接受这个类型,则可以直接返回输入的对象
  *
  * @param val get 后的值
  * @param check 是否严格检查
  * @return 修改 get 后的值,这个值是 ejecting 从对象中取出的
  */
 public Object adaptForGet(Object val, boolean check) {
   if (null != val && CoIdType.DEFAULT == field.getIdType() && !(val instanceof ObjectId)) {
     String s = val.toString();
     if (!Mongos.isDefaultMongoId(s))
       throw Lang.makeThrow("Expect Mongo ID format, but is was '%s'", s);
     return new ObjectId(s);
   }
   return val;
 }
예제 #3
0
 @Override
 public Message setFavorite(Message msg, boolean favo) {
   if (null == msg) return null;
   return dao.findAndModify(Message.class, Mongos.dboId(msg.get_id()), Moo.SET("favorite", favo));
 }
예제 #4
0
 @Override
 public Message setRead(Message msg, boolean read) {
   if (null == msg) return null;
   return dao.findAndModify(Message.class, Mongos.dboId(msg.get_id()), Moo.SET("read", read));
 }
예제 #5
0
 @Override
 public Message remove(String msgId) {
   return dao.findAndRemove(Message.class, Mongos.dboId(msgId));
 }
예제 #6
0
 @Override
 public Message setNotified(Message msg, Date d) {
   if (null == msg) return null;
   return dao.findAndModify(Message.class, Mongos.dboId(msg.get_id()), Moo.SET("notified", d));
 }