public Person_login createPerson(Person_login p) { DBObject doc = PersonConverter.toDBObject(p); this.col.insert(doc); ObjectId id = (ObjectId) doc.get("_id"); p.setId(id.toString()); return p; }
public List<Person_login> readAllPerson() { List<Person_login> data = new ArrayList<Person_login>(); DBCursor cursor = col.find(); while (cursor.hasNext()) { DBObject doc = cursor.next(); Person_login p = PersonConverter.toPerson(doc); data.add(p); } return data; }
public Person_login getPerson(String email) { DBObject query = BasicDBObjectBuilder.start().append("email", email).get(); DBObject data = this.col.findOne(query); if (data == null) { return null; } else { return PersonConverter.toPerson(data); } }
public Person_login readPerson(Person_login p) { DBObject query = BasicDBObjectBuilder.start().append("_id", new ObjectId(p.getId())).get(); DBObject data = this.col.findOne(query); return PersonConverter.toPerson(data); }
public void updatePerson(Person_login p) { DBObject query = BasicDBObjectBuilder.start().append("_id", new ObjectId(p.getId())).get(); this.col.update(query, PersonConverter.toDBObject(p)); }