Pārlūkot izejas kodu

Mongodb补充分页示例

miaozy 4 gadi atpakaļ
vecāks
revīzija
083722aa39

+ 0 - 11
ipu-mongodb-example/src/test/java/com/ai/ipu/example/mongodb/MongodbExample.java

@ -208,17 +208,6 @@ public class MongodbExample extends TestCase {
208 208
  }
209 209

210 210
  /**
211
   * 查询符合条件的所有数据(分页)
212
   *
213
   * @throws Exception
214
   */
215
  public void testExecuteSelectByPage() throws Exception {
216
    JSONObject cond = new JSONObject();
217
    cond.put("nickName", "tom");
218
    log.debug("查询结果为:" + noSql.executeSelect(cond.toJSONString()));
219
  }
220

221
  /**
222 211
   * 设置返回记录的最大条数,查询符合条件的数据。
223 212
   * 类似mysql的limit
224 213
   * 类似oracle的rownum

+ 10 - 1
ipu-mongodb-example/src/test/java/com/ai/ipu/example/mongodb/MongodbExampleWithSql.java

@ -69,6 +69,15 @@ public class MongodbExampleWithSql extends TestCase {
69 69
    noSql.executeUpdate("update mycol1 set remarks = '2' where name = 'test'");
70 70
  }
71 71
72
73
  /**
74
   * 使用标准SQL条件查询mongodb(分页)
75
   * @throws Exception
76
   */
77
  public void testExecuteSelect1() throws Exception {
78
    log.debug("查询结果为:" + noSql.executeSelect("select * from mycol1 limit 0,5"));
79
  }
80
72 81
  /**
73 82
   * 使用标准SQL,where条件查询mongodb
74 83
   * 简单的汇总计数
@ -135,7 +144,7 @@ public class MongodbExampleWithSql extends TestCase {
135 144
   * 分类汇总
136 145
   * @throws Exception
137 146
   */
138
  public void testExecuteSelect1() throws Exception {
147
  public void testExecuteSelect8() throws Exception {
139 148
    log.debug("查询结果为:" + noSql.executeSelect("select name,nickName,sum(age) sumAge,count(1) totalNum from mycol1 where name != 'mike' group by name,nickName  having sumAge>=10 order by sumAge desc"));
140 149
  }
141 150
}