Exemple #1
0
 @Before(MongoValidator.class)
 public void save() {
   String name = getPara("name");
   Record record = new Record().set("name", name);
   MongoKit.save("movie", record);
   redirect("/");
 }
Exemple #2
0
 public void update() {
   Map<String, Object> src = new HashMap<String, Object>();
   src.put("_id", new ObjectId(getPara("id")));
   String name = getPara("name");
   Map<String, Object> desc = new HashMap<String, Object>();
   desc.put("name", name);
   MongoKit.updateFirst("movie", src, desc); // 只能修改符合条件的第一条数据..
   redirect("/");
 }
Exemple #3
0
 public void edit() {
   /*
    * Map<String, Object> filter = new HashMap<String, Object>(); filter.put( "_id", new
    * ObjectId(getPara())); Page<Record> page = MongoKit.paginate("movie", 1, 10, filter);
    * setAttr("this", page);
    */
   DBCollection movie = MongoKit.getCollection("movie");
   setAttr("this", movie.findOne(new ObjectId(getPara())));
 }
Exemple #4
0
  public void index() {

    // Map<String, Object> filter = new HashMap<String, Object>();
    // filter.put("name", "haha") ; //精确过滤
    // Map<String, Object> like = new HashMap<String, Object>();
    // like.put("name","haha"); //模糊匹配,相当于sql 的like %zhang%
    // Map<String, Object> sort = new HashMap<String, Object>();
    // sort.put("id", "desc"); // 排序
    // Page<Record> page = MongoKit.paginate("movie", 1, 3);
    setAttr("Page", MongoKit.paginate("movie", getParaToInt(0, 1), 3));
    render("mongo.html");
  }
Exemple #5
0
 public void delete() {
   MongoKit.remove("movie", new BasicDBObject("_id", new ObjectId(getPara())));
   redirect("/");
 }