http://www.sequoiadb.com/document/1.8/index.html
MDB.initCollection(Const.USER).delete("{}");
MDB.initCollection(Const.USER).insert("{'acc':'acc100'}");
MDB.initCollection(Const.USER).insert("{'acc':'acc101'}");
MDB.initCollection(Const.USER).insert("{'acc':'acc102'}");
System.out.println(""+ MDB.cur2jsonstr(MDB.query(Const.USER,"{acc:{$gt:'acc100'}}",2)));
System.out.println(""+ MDB.cur2jsonstr(MDB.query(Const.USER,"{acc:{ $regex : '^acc', \"$options\" : \"i\" }}",2)));
System.out.println(""+ MDB.cur2jsonstr(MDB.query(Const.USER,"{acc:{ \"$regex\" : \"^acc\", \"$options\" : \"i\" }}",2)));
run:
D:\working\workspace\LF_S_SignalProc/sdbdriver.properties
{ "_id" : { "$oid" : "5424d47b6bbd9bd45f30ceff"} , "acc" : "acc101"}{ "_id" : { "$oid" : "5424d47b6bbd9bd45f30cf00"} , "acc" : "acc102"}
{ "_id" : { "$oid" : "5424d47b6bbd9bd45f30cefe"} , "acc" : "acc100"}{ "_id" : { "$oid" : "5424d47b6bbd9bd45f30ceff"} , "acc" : "acc101"}
{ "_id" : { "$oid" : "5424d47b6bbd9bd45f30cefe"} , "acc" : "acc100"}{ "_id" : { "$oid" : "5424d47b6bbd9bd45f30ceff"} , "acc" : "acc101"}
成功构建 (总时间: 0 秒)
public static DBCursor query(String cl,String matcher,long returnRows) {
return initCollection(cl).query( matcher, null,null,null, 0L, returnRows);
}
public static String cur2jsonstr(DBCursor c) {
String jsonString = "";
if (c != null && c.hasNext()) {
List list = new ArrayList();
while (c.hasNext()) {
jsonString = jsonString+(c.getNext().toString());
}
return jsonString;
}
return "{}";
}