コード例 #1
0
ファイル: DriverMongo.java プロジェクト: riking/mcore
 @Override
 public Long getMtime(Coll<?> coll, String id) {
   DBCollection dbcoll = fixColl(coll);
   BasicDBObject found =
       (BasicDBObject) dbcoll.findOne(new BasicDBObject(ID_FIELD, id), dboKeysMtime);
   if (found == null) return null;
   if (!found.containsField(MTIME_FIELD))
     return null; // This should not happen! But better to ignore than crash?
   return found.getLong(MTIME_FIELD);
 }
コード例 #2
0
ファイル: DriverMongo.java プロジェクト: riking/mcore
  @Override
  public Entry<JsonElement, Long> load(Coll<?> coll, String id) {
    DBCollection dbcoll = fixColl(coll);
    BasicDBObject raw = (BasicDBObject) dbcoll.findOne(new BasicDBObject(ID_FIELD, id));
    if (raw == null) return null;

    Long mtime = ((Number) raw.removeField(MTIME_FIELD)).longValue();
    raw.removeField(ID_FIELD);

    JsonElement element = GsonMongoConverter.mongo2GsonObject(raw);

    return new SimpleEntry<JsonElement, Long>(element, mtime);
  }