Package org.springframework.data.mongodb.core.query

Examples of org.springframework.data.mongodb.core.query.BasicQuery.sort()


        System.out.println(query.toQuery().toString());

        Query bquery = new BasicQuery(query.toQuery());
        bquery.limit(100);

        bquery.sort().on("$timestamp", Order.DESCENDING);
        System.out.println(bquery.getQueryObject());
        System.out.println(bquery.getFieldsObject());
        System.out.println(bquery.getSortObject());
//        assertEquals("{ \"timestamp\" : { \"$gt\" : { \"$date\" : \"1970-01-01T00:01:40.000Z\"}} , \"$where\" : \"this.message && this.message.match('hello')\"}",query.toQuery().toString());
    }
View Full Code Here


        MongoTemplate template = project.fetchMongoTemplate();

        Query query = new BasicQuery(logQuery.toQuery());
        query.limit(max);

        query.sort().on("timestamp", Order.DESCENDING);
        logger.debug("find logs from {}  by query {} by sort {}", new Object[]{project.getLogCollection(), query.getQueryObject(), query.getSortObject()});
        DBCursor cursor = template.getCollection(project.getLogCollection()).find(query.getQueryObject()).sort(query.getSortObject()).limit(max);
        return cursor;
    }
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.