public Todo update(String todoId, String body) { Todo todo = new Gson().fromJson(body, Todo.class); collection.update( new BasicDBObject("_id", new ObjectId(todoId)), new BasicDBObject("$set", new BasicDBObject("done", todo.isDone()))); return this.find(todoId); }
public void createNewTodo(String body) { Todo todo = new Gson().fromJson(body, Todo.class); collection.insert( new BasicDBObject("title", todo.getTitle()) .append("done", todo.isDone()) .append("createdOn", new Date())); }