Package com.mongodb

Examples of com.mongodb.DBCursor.toArray()


            if (limit != null) {
                ret.limit(limit.intValue());
            }

            Message resultMessage = prepareResponseMessage(exchange, MongoDbOperation.findAll);
            resultMessage.setBody(ret.toArray());
            resultMessage.setHeader(MongoDbConstants.RESULT_TOTAL_SIZE, ret.count());
            resultMessage.setHeader(MongoDbConstants.RESULT_PAGE_SIZE, ret.size());
        } finally {
            // make sure the cursor is closed
            if (ret != null) {
View Full Code Here


    }

    public List<DBObject> find() {
        if (null != _coll) {
            final DBCursor cursor = _coll.find();
            return null != cursor ? cursor.toArray() : new ArrayList<DBObject>();
        }
        return null;
    }

    public List<DBObject> find(final String[] fieldNames) {
View Full Code Here

            final String[] sortAscBy, final String[] sortDescBy) {
        if (null != _coll) {
            final DBCursor cursor = this.cursor(
                    filter, fieldNames, 0, 0, sortAscBy, sortDescBy);
            return null != cursor
                    ? cursor.toArray()
                    : new ArrayList<DBObject>();
        }
        return null;
    }
   
View Full Code Here

            final String[] sortAscBy, final String[] sortDescBy) {
        if (null != _coll) {
            final DBCursor cursor = this.cursor(
                    filter, fieldNames, skip, limit, sortAscBy, sortDescBy);
            return null != cursor
                    ? cursor.toArray()
                    : new ArrayList<DBObject>();
        }
        return null;
    }
View Full Code Here

            if (limit != null) {
                ret.limit(limit.intValue());
            }
           
            Message resultMessage = prepareResponseMessage(exchange, MongoDbOperation.findAll);
            resultMessage.setBody(ret.toArray());
            resultMessage.setHeader(MongoDbConstants.RESULT_TOTAL_SIZE, ret.count());
            resultMessage.setHeader(MongoDbConstants.RESULT_PAGE_SIZE, ret.size());
           
        } catch (Exception e) {
            // rethrow the exception
View Full Code Here

    public List<DBObject> findByDateDescending(int limit) {
        List<DBObject> posts;
        DBCursor cursor = postsCollection.find().sort(new BasicDBObject().append("date", -1)).limit(limit);
        try {
            posts = cursor.toArray();
        } finally {
            cursor.close();
        }
        return posts;
    }
View Full Code Here

        List<DBObject> posts;
        BasicDBObject query = new BasicDBObject("tags", tag);
        System.out.println("/tag query: " + query.toString());
        DBCursor cursor = postsCollection.find(query).sort(new BasicDBObject().append("date", -1)).limit(10);
        try {
            posts = cursor.toArray();
        } finally {
            cursor.close();
        }
        return posts;
    }
View Full Code Here

    public List<DBObject> findByDateDescending(int limit) {
        List<DBObject> posts;
        DBCursor cursor = postsCollection.find().sort(new BasicDBObject().append("date", -1)).limit(limit);
        try {
            posts = cursor.toArray();
        } finally {
            cursor.close();
        }
        return posts;
    }
View Full Code Here

        List<DBObject> posts;
        BasicDBObject query = new BasicDBObject("tags", tag);
        System.out.println("/tag query: " + query.toString());
        DBCursor cursor = postsCollection.find(query).sort(new BasicDBObject().append("date", -1)).limit(10);
        try {
            posts = cursor.toArray();
        } finally {
            cursor.close();
        }
        return posts;
    }
View Full Code Here

    BasicDBObject condition = new BasicDBObject();
    condition.put(OWNER_ID, ownerId);
    BasicDBObject orderBy = new BasicDBObject();
    orderBy.put(TIME, -1);
    DBCursor cursor = collections.get(level).find(condition).limit(1).sort(orderBy);
    List<DBObject> feed = cursor.toArray();
    if (feed != null && feed.size() > 0) {
      return feed.get(0);
    } else {
      return null;
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.