FirebaseFireStore return true for isSuccess after I try to delete a document that already created
up vote
1
down vote
favorite
I accidentally found this after I test my application. I have a recycleListView that contains cardview which each one has a document from firestore. After I delete some document randomly, it disappear from FirebaseFirestore, but when I try to delete it again it still return isSuccess() true. Can someone explain me why this happen?
This is my code that I use to delete document from Collection.
FirebaseFirestore.getInstance().collection("Collection_A")
.document(list[position].id).delete().apply {
addOnCompleteListener { task ->
if (task.isComplete){
Log.d("Complete", "Task complete")
}
if (task.isSuccessful) {
Log.d("Complete", "Task complete and Success")
} else {
Log.d("Complete", "Task complete but not success")
}
}
addOnCanceledListener {
Log.d("Cancel", "Delete data canceled")
}
addOnFailureListener { ex ->
ex.printStackTrace()
}
My Document Structure
Collection_A
Docoument… [Document ID generated randomly]
name [field]: String
count [field]: Int
dateInWeek [field]: Map < String, Boolean >
android firebase google-cloud-firestore
add a comment |
up vote
1
down vote
favorite
I accidentally found this after I test my application. I have a recycleListView that contains cardview which each one has a document from firestore. After I delete some document randomly, it disappear from FirebaseFirestore, but when I try to delete it again it still return isSuccess() true. Can someone explain me why this happen?
This is my code that I use to delete document from Collection.
FirebaseFirestore.getInstance().collection("Collection_A")
.document(list[position].id).delete().apply {
addOnCompleteListener { task ->
if (task.isComplete){
Log.d("Complete", "Task complete")
}
if (task.isSuccessful) {
Log.d("Complete", "Task complete and Success")
} else {
Log.d("Complete", "Task complete but not success")
}
}
addOnCanceledListener {
Log.d("Cancel", "Delete data canceled")
}
addOnFailureListener { ex ->
ex.printStackTrace()
}
My Document Structure
Collection_A
Docoument… [Document ID generated randomly]
name [field]: String
count [field]: Int
dateInWeek [field]: Map < String, Boolean >
android firebase google-cloud-firestore
Please add the code that you are using and your database structure with an example of such a document.
– Alex Mamo
Nov 22 at 10:50
I'm already add my code and sample data structure. :)
– Hello World
Nov 22 at 11:08
1
I don't understand what is theapply
call after thedelete()
call and what is the value oflist[position].id
or how is that list defined. I might be better if you provide a screenshot of your database.
– Alex Mamo
Nov 22 at 11:31
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I accidentally found this after I test my application. I have a recycleListView that contains cardview which each one has a document from firestore. After I delete some document randomly, it disappear from FirebaseFirestore, but when I try to delete it again it still return isSuccess() true. Can someone explain me why this happen?
This is my code that I use to delete document from Collection.
FirebaseFirestore.getInstance().collection("Collection_A")
.document(list[position].id).delete().apply {
addOnCompleteListener { task ->
if (task.isComplete){
Log.d("Complete", "Task complete")
}
if (task.isSuccessful) {
Log.d("Complete", "Task complete and Success")
} else {
Log.d("Complete", "Task complete but not success")
}
}
addOnCanceledListener {
Log.d("Cancel", "Delete data canceled")
}
addOnFailureListener { ex ->
ex.printStackTrace()
}
My Document Structure
Collection_A
Docoument… [Document ID generated randomly]
name [field]: String
count [field]: Int
dateInWeek [field]: Map < String, Boolean >
android firebase google-cloud-firestore
I accidentally found this after I test my application. I have a recycleListView that contains cardview which each one has a document from firestore. After I delete some document randomly, it disappear from FirebaseFirestore, but when I try to delete it again it still return isSuccess() true. Can someone explain me why this happen?
This is my code that I use to delete document from Collection.
FirebaseFirestore.getInstance().collection("Collection_A")
.document(list[position].id).delete().apply {
addOnCompleteListener { task ->
if (task.isComplete){
Log.d("Complete", "Task complete")
}
if (task.isSuccessful) {
Log.d("Complete", "Task complete and Success")
} else {
Log.d("Complete", "Task complete but not success")
}
}
addOnCanceledListener {
Log.d("Cancel", "Delete data canceled")
}
addOnFailureListener { ex ->
ex.printStackTrace()
}
My Document Structure
Collection_A
Docoument… [Document ID generated randomly]
name [field]: String
count [field]: Int
dateInWeek [field]: Map < String, Boolean >
android firebase google-cloud-firestore
android firebase google-cloud-firestore
edited Nov 22 at 11:07
asked Nov 22 at 10:44
Hello World
16011
16011
Please add the code that you are using and your database structure with an example of such a document.
– Alex Mamo
Nov 22 at 10:50
I'm already add my code and sample data structure. :)
– Hello World
Nov 22 at 11:08
1
I don't understand what is theapply
call after thedelete()
call and what is the value oflist[position].id
or how is that list defined. I might be better if you provide a screenshot of your database.
– Alex Mamo
Nov 22 at 11:31
add a comment |
Please add the code that you are using and your database structure with an example of such a document.
– Alex Mamo
Nov 22 at 10:50
I'm already add my code and sample data structure. :)
– Hello World
Nov 22 at 11:08
1
I don't understand what is theapply
call after thedelete()
call and what is the value oflist[position].id
or how is that list defined. I might be better if you provide a screenshot of your database.
– Alex Mamo
Nov 22 at 11:31
Please add the code that you are using and your database structure with an example of such a document.
– Alex Mamo
Nov 22 at 10:50
Please add the code that you are using and your database structure with an example of such a document.
– Alex Mamo
Nov 22 at 10:50
I'm already add my code and sample data structure. :)
– Hello World
Nov 22 at 11:08
I'm already add my code and sample data structure. :)
– Hello World
Nov 22 at 11:08
1
1
I don't understand what is the
apply
call after the delete()
call and what is the value of list[position].id
or how is that list defined. I might be better if you provide a screenshot of your database.– Alex Mamo
Nov 22 at 11:31
I don't understand what is the
apply
call after the delete()
call and what is the value of list[position].id
or how is that list defined. I might be better if you provide a screenshot of your database.– Alex Mamo
Nov 22 at 11:31
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
I just quickly tested and it seems that on JavaScript too the delete is considered successful even if the document no longer exists. So it sounds like this is working as expected, and you should probably label it as "the task is successful when the document no longer exists in the database". The task will only fail if you don't have permission to delete the document (whether it exists or not).
If you want to test whether a document exists, use a get()
operation.
If you want to atomically detect whether the document exists and delete it, use a transaction.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53429160%2ffirebasefirestore-return-true-for-issuccess-after-i-try-to-delete-a-document-tha%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
I just quickly tested and it seems that on JavaScript too the delete is considered successful even if the document no longer exists. So it sounds like this is working as expected, and you should probably label it as "the task is successful when the document no longer exists in the database". The task will only fail if you don't have permission to delete the document (whether it exists or not).
If you want to test whether a document exists, use a get()
operation.
If you want to atomically detect whether the document exists and delete it, use a transaction.
add a comment |
up vote
1
down vote
I just quickly tested and it seems that on JavaScript too the delete is considered successful even if the document no longer exists. So it sounds like this is working as expected, and you should probably label it as "the task is successful when the document no longer exists in the database". The task will only fail if you don't have permission to delete the document (whether it exists or not).
If you want to test whether a document exists, use a get()
operation.
If you want to atomically detect whether the document exists and delete it, use a transaction.
add a comment |
up vote
1
down vote
up vote
1
down vote
I just quickly tested and it seems that on JavaScript too the delete is considered successful even if the document no longer exists. So it sounds like this is working as expected, and you should probably label it as "the task is successful when the document no longer exists in the database". The task will only fail if you don't have permission to delete the document (whether it exists or not).
If you want to test whether a document exists, use a get()
operation.
If you want to atomically detect whether the document exists and delete it, use a transaction.
I just quickly tested and it seems that on JavaScript too the delete is considered successful even if the document no longer exists. So it sounds like this is working as expected, and you should probably label it as "the task is successful when the document no longer exists in the database". The task will only fail if you don't have permission to delete the document (whether it exists or not).
If you want to test whether a document exists, use a get()
operation.
If you want to atomically detect whether the document exists and delete it, use a transaction.
edited Nov 22 at 17:38
answered Nov 22 at 15:21
Frank van Puffelen
224k26364391
224k26364391
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53429160%2ffirebasefirestore-return-true-for-issuccess-after-i-try-to-delete-a-document-tha%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Please add the code that you are using and your database structure with an example of such a document.
– Alex Mamo
Nov 22 at 10:50
I'm already add my code and sample data structure. :)
– Hello World
Nov 22 at 11:08
1
I don't understand what is the
apply
call after thedelete()
call and what is the value oflist[position].id
or how is that list defined. I might be better if you provide a screenshot of your database.– Alex Mamo
Nov 22 at 11:31