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 >














share|improve this question
























  • 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 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















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 >














share|improve this question
























  • 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 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













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 >














share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 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


















  • 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 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
















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












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.






share|improve this answer























    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
    });


    }
    });














    draft saved

    draft discarded


















    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.






    share|improve this answer



























      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.






      share|improve this answer

























        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.






        share|improve this answer














        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.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 22 at 17:38

























        answered Nov 22 at 15:21









        Frank van Puffelen

        224k26364391




        224k26364391






























            draft saved

            draft discarded




















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            Contact image not getting when fetch all contact list from iPhone by CNContact

            count number of partitions of a set with n elements into k subsets

            A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks