0
내 JS 코드 :데이터는 MongoDB를에서 삭제하지 마십시오
$scope.del = function (record) {
if (confirm('Do you really want to delete?')){
$http['delete']('/camera/list/' + record.filename).then(function() {
$scope.records.splice($scope.records.indexOf(record), 1);
});
}
};
내 HTML 코드 :
@RequestMapping(value = "/list/{fn}", method = RequestMethod.DELETE)
public ResponseEntity<Record> deleteUser(@PathVariable("fn") String filename) {
System.out.println("Fetching & Deleting data " + filename);
Record user1 = rep.findByfilename(filename);
if (user1 == null) {
System.out.println("Unable to delete. " + filename + " not found");
return new ResponseEntity<Record>(HttpStatus.NOT_FOUND);
}
rep.deleteUserById(filename);
return new ResponseEntity<Record>(HttpStatus.NO_CONTENT);
}
}
내가 삭제 컨트롤러를 생성하지만 여전히 않습니다 : 내 컨트롤러가
<td><button class="btn" ng-click="del(record)">Delete</button></td>
내 mongodb에서 데이터를 제거하지 않고 내 gui 자체의 데이터 만 제거 할 수 있습니다. 아무도 내가 뭘 잘못했는지 알 수있게 도와 줄 수 있니? 나는 오류가 없기 때문에.
'rep.deleteUserById (user1._id)'와 같아야합니까? –
하지만 _id 대신 파일명으로 삭제합니다 –
그럼'rep.deleteUserByFilename'을 사용할 수 있습니까? –