1
MongoDB 문서를 읽었지만 잘 이해하지 못했습니다! 다음 코드가 올바른지 알아야합니다! 작업이 성공적으로 수행되면 확인이 필요합니다. getLastError를 호출 할 필요가 있거나 try-catch로 충분합니까?올바른 방법으로 mongodb 드라이버를 사용하여이 삭제 코드를 수행합니까?
public override bool DeleteUser(string username, bool deleteAllRelatedData)
{
WriteConcernResult result = null;
try
{
result = this.users.Remove(Query.And(Query.EQ("ApplicationName",
this.ApplicationName), Query.EQ("Username", username)), RemoveFlags.Single,
WriteConcern.Acknowledged);
if (result.HasLastErrorMessage)
{
return false;
}
return (result.DocumentsAffected == 1);
}
catch (Exception ex)
{
return false;
}
}