Package com.massivecraft.mcore.xlib.mongodb

Examples of com.massivecraft.mcore.xlib.mongodb.DBCursor


     * @throws MongoException
     */
    public List<GridFSDBFile> find( DBObject query , DBObject sort){
        List<GridFSDBFile> files = new ArrayList<GridFSDBFile>();

        DBCursor c = null;
        try {
            c = _filesCollection.find( query );
            if (sort != null) {
                c.sort(sort);
            }
            while ( c.hasNext() ){
                files.add( _fix( c.next() ) );
            }
        } finally {
             if (c != null){
                 c.close();
             }
        }
        return files;
    }
View Full Code Here


 
  @Override
  public boolean containsId(Coll<?> coll, String id)
  {
    DBCollection dbcoll = fixColl(coll);
    DBCursor cursor = dbcoll.find(new BasicDBObject(ID_FIELD, id));
    return cursor.count() != 0;
  }
View Full Code Here

  {
    List<String> ret = null;
   
    DBCollection dbcoll = fixColl(coll);
   
    DBCursor cursor = dbcoll.find(dboEmpty, dboKeysId);
    try
    {
      ret = new ArrayList<String>(cursor.count());
      while(cursor.hasNext())
      {
        Object remoteId = cursor.next().get(ID_FIELD);
        ret.add(remoteId.toString());
      }
    }
    finally
    {
      cursor.close();
    }
   
    return ret;
  }
View Full Code Here

  {
    Map<String, Long> ret = null;
   
    DBCollection dbcoll = fixColl(coll);
   
    DBCursor cursor = dbcoll.find(dboEmpty, dboKeysIdandMtime);
    try
    {
      ret = new HashMap<String, Long>(cursor.count());
      while(cursor.hasNext())
      {
        BasicDBObject raw = (BasicDBObject)cursor.next();
        Object remoteId = raw.get(ID_FIELD);
        if ( ! raw.containsField(MTIME_FIELD)) continue; // This should not happen! But better to ignore than crash?
        Long mtime = raw.getLong(MTIME_FIELD);
        ret.put(remoteId.toString(), mtime);
      }
    }
    finally
    {
      cursor.close();
    }
   
    return ret;
  }
View Full Code Here

TOP

Related Classes of com.massivecraft.mcore.xlib.mongodb.DBCursor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.