Package com.mongodb

Examples of com.mongodb.DBCollection.find()


            long startTime, long endTime) throws ManifoldCFException, ServiceInterruption {
        getSession();
        DBCollection fsFiles = session.getCollection(
                bucket + GridFSConstants.COLLECTION_SEPERATOR + GridFSConstants.FILES_COLLECTION_NAME
        );
        DBCursor dnc = fsFiles.find();
        while (dnc.hasNext()) {
            DBObject dbo = dnc.next();
            String _id = dbo.get("_id").toString();
            activities.addSeedDocument(_id);
            if (Logging.connectors.isDebugEnabled()) {
View Full Code Here


            );
        }

        QueryBuilder builder = QueryBuilder.start("start.x").greaterThan(50);

        DBCursor cursor = lines.find(builder.get(),
                new BasicDBObject("start.y", true).append("_id", false));

        try {
            while (cursor.hasNext()) {
                DBObject cur = cursor.next();
View Full Code Here

        }

        DBObject query = QueryBuilder.start("x").is(0)
                .and("y").greaterThan(10).lessThan(70).get();

        DBCursor cursor = collection.find(query,
                new BasicDBObject("y", true).append("_id", false));
        try {
            while (cursor.hasNext()) {
                DBObject cur = cursor.next();
                System.out.println(cur);
View Full Code Here

        System.out.println("Find one:");
        DBObject one = collection.findOne();
        System.out.println(one);

        System.out.println("\nFind all: ");
        DBCursor cursor = collection.find();
        try {
          while (cursor.hasNext()) {
              DBObject cur = cursor.next();
              System.out.println(cur);
          }
View Full Code Here

        System.out.println("\nCount:");
        long count = collection.count(builder.get());
        System.out.println(count);

        System.out.println("\nFind all: ");
        DBCursor cursor = collection.find(builder.get());
        try {
            while (cursor.hasNext()) {
                DBObject cur = cursor.next();
                System.out.println(cur);
            }
View Full Code Here

                                              .append("y", rand.nextInt(90) + 10)
                            )
            );
        }

        DBCursor cursor = lines.find()
                .sort(new BasicDBObject("start.x", 1).append("start.y", -1))
                .skip(2).limit(10);

        try {
            while (cursor.hasNext()) {
View Full Code Here

        long count = collection.count(query);
        System.out.println(count);

        System.out.println("\nFind all: ");
        DBCursor cursor = collection.find(query)
                                    .sort(new BasicDBObject("student_id", 1).append("score", 1));

        //scratch(collection);
        int prevStudentId = -1;
        while (cursor.hasNext()) {
View Full Code Here

        // DBObject doc = c.find(query).hint("a_1_b_-1_c_1").explain();

        BasicDBObject myHint = new BasicDBObject("a", 1).append("b",-1).append("c", 1);

        DBObject doc = c.find(query).hint(myHint).explain();




View Full Code Here

        DB db = client.getDB("course");
        db.setReadPreference(ReadPreference.primary());
        DBCollection coll = db.getCollection("write.test");
        coll.setReadPreference(ReadPreference.primaryPreferred());

        DBCursor cursor = coll.find().setReadPreference(ReadPreference.nearest());
        try {
            while (cursor.hasNext()) {
                System.out.println(cursor.next());
            }
        } finally {
View Full Code Here

    public static void main(String[] args) throws UnknownHostException {
        MongoClient mongoClient = new MongoClient();
        DB school = mongoClient.getDB("school");
        DBCollection studentsCollection = school.getCollection("students");

        DBCursor students = studentsCollection.find();

        DBObject student = null;
        while(students.hasNext()) {
            student = students.next();
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.