papyhardcore

Add to DB

Sep 4th, 2014
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.44 KB | None | 0 0
  1.  public boolean add(){
  2.         DBCollection coll = Db.databse.getCollection("Roles");
  3.         DBObject r = new BasicDBObject();
  4.         r.put("name",this.getName());
  5.         DBObject result =  coll.findOne(r);
  6.  
  7.         if(result != null){
  8.             System.out.print("Nop");
  9.             return false;
  10.         }else{
  11.             r.put("description",this.getDescription());
  12.             coll.save(r);
  13.             return true;
  14.         }
  15.     }
Advertisement
Add Comment
Please, Sign In to add comment