Filter in specific firebase structure












0















I looking for method how to filtering my firebase. I know that is on stack overflow a lot of examples but my configuration is different - see below:



enter image description here



and my code to fetch data is:



let usersDatabaseRef = Database.database().reference().child("usersDatabase").child(userID).child("Customers")
usersDatabaseRef.observeSingleEvent(of: .value, with: { (snapshot) in
for child in snapshot.children {
let childSnap = child as! DataSnapshot
let userCustomerSnap = childSnap

for customer in userCustomerSnap.children.allObjects as! [DataSnapshot] {
let customerSnap = customer
let dict = customerSnap.value as! [String: Any]

let employee = dict["Assigned employee"]


then I appending employee to my Model.
Is possible to filter my cells in tableView by employee? (when I tap on button with name of employee tableView should showing only its services)










share|improve this question

























  • You're going to run into a LOT of problems with this structure and it's unclear what 'filter' means in this use case. Are you asking if you can query for a node that contains a single employee? Or something else? As it is, you're getting all the child nodes within Customer so you could put each child node's data in an object, store those objects in an array and 'filter' them. But is that what you're asking how to do?

    – Jay
    Dec 29 '18 at 14:41













  • There is some debate about using email addresses as keys but for me, I discourage it. See emails as keys are evil. Also, if Alice Glockam gets married and changes her name to Alice Smith; what are you going to do? Well, you'll have to find, delete and re-create every node in your database referring to Alice Glockam.

    – Jay
    Dec 29 '18 at 14:49













  • oh - and the data may be too deep so you may want to denormalize it. Lastly, PLEASE include structures as text, not images, in questions.

    – Jay
    Dec 29 '18 at 14:49
















0















I looking for method how to filtering my firebase. I know that is on stack overflow a lot of examples but my configuration is different - see below:



enter image description here



and my code to fetch data is:



let usersDatabaseRef = Database.database().reference().child("usersDatabase").child(userID).child("Customers")
usersDatabaseRef.observeSingleEvent(of: .value, with: { (snapshot) in
for child in snapshot.children {
let childSnap = child as! DataSnapshot
let userCustomerSnap = childSnap

for customer in userCustomerSnap.children.allObjects as! [DataSnapshot] {
let customerSnap = customer
let dict = customerSnap.value as! [String: Any]

let employee = dict["Assigned employee"]


then I appending employee to my Model.
Is possible to filter my cells in tableView by employee? (when I tap on button with name of employee tableView should showing only its services)










share|improve this question

























  • You're going to run into a LOT of problems with this structure and it's unclear what 'filter' means in this use case. Are you asking if you can query for a node that contains a single employee? Or something else? As it is, you're getting all the child nodes within Customer so you could put each child node's data in an object, store those objects in an array and 'filter' them. But is that what you're asking how to do?

    – Jay
    Dec 29 '18 at 14:41













  • There is some debate about using email addresses as keys but for me, I discourage it. See emails as keys are evil. Also, if Alice Glockam gets married and changes her name to Alice Smith; what are you going to do? Well, you'll have to find, delete and re-create every node in your database referring to Alice Glockam.

    – Jay
    Dec 29 '18 at 14:49













  • oh - and the data may be too deep so you may want to denormalize it. Lastly, PLEASE include structures as text, not images, in questions.

    – Jay
    Dec 29 '18 at 14:49














0












0








0








I looking for method how to filtering my firebase. I know that is on stack overflow a lot of examples but my configuration is different - see below:



enter image description here



and my code to fetch data is:



let usersDatabaseRef = Database.database().reference().child("usersDatabase").child(userID).child("Customers")
usersDatabaseRef.observeSingleEvent(of: .value, with: { (snapshot) in
for child in snapshot.children {
let childSnap = child as! DataSnapshot
let userCustomerSnap = childSnap

for customer in userCustomerSnap.children.allObjects as! [DataSnapshot] {
let customerSnap = customer
let dict = customerSnap.value as! [String: Any]

let employee = dict["Assigned employee"]


then I appending employee to my Model.
Is possible to filter my cells in tableView by employee? (when I tap on button with name of employee tableView should showing only its services)










share|improve this question
















I looking for method how to filtering my firebase. I know that is on stack overflow a lot of examples but my configuration is different - see below:



enter image description here



and my code to fetch data is:



let usersDatabaseRef = Database.database().reference().child("usersDatabase").child(userID).child("Customers")
usersDatabaseRef.observeSingleEvent(of: .value, with: { (snapshot) in
for child in snapshot.children {
let childSnap = child as! DataSnapshot
let userCustomerSnap = childSnap

for customer in userCustomerSnap.children.allObjects as! [DataSnapshot] {
let customerSnap = customer
let dict = customerSnap.value as! [String: Any]

let employee = dict["Assigned employee"]


then I appending employee to my Model.
Is possible to filter my cells in tableView by employee? (when I tap on button with name of employee tableView should showing only its services)







ios swift firebase firebase-realtime-database tableview






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 29 '18 at 13:17









Robert Dresler

5,6131526




5,6131526










asked Dec 29 '18 at 13:13









Krzysztof ŁowiecKrzysztof Łowiec

12




12













  • You're going to run into a LOT of problems with this structure and it's unclear what 'filter' means in this use case. Are you asking if you can query for a node that contains a single employee? Or something else? As it is, you're getting all the child nodes within Customer so you could put each child node's data in an object, store those objects in an array and 'filter' them. But is that what you're asking how to do?

    – Jay
    Dec 29 '18 at 14:41













  • There is some debate about using email addresses as keys but for me, I discourage it. See emails as keys are evil. Also, if Alice Glockam gets married and changes her name to Alice Smith; what are you going to do? Well, you'll have to find, delete and re-create every node in your database referring to Alice Glockam.

    – Jay
    Dec 29 '18 at 14:49













  • oh - and the data may be too deep so you may want to denormalize it. Lastly, PLEASE include structures as text, not images, in questions.

    – Jay
    Dec 29 '18 at 14:49



















  • You're going to run into a LOT of problems with this structure and it's unclear what 'filter' means in this use case. Are you asking if you can query for a node that contains a single employee? Or something else? As it is, you're getting all the child nodes within Customer so you could put each child node's data in an object, store those objects in an array and 'filter' them. But is that what you're asking how to do?

    – Jay
    Dec 29 '18 at 14:41













  • There is some debate about using email addresses as keys but for me, I discourage it. See emails as keys are evil. Also, if Alice Glockam gets married and changes her name to Alice Smith; what are you going to do? Well, you'll have to find, delete and re-create every node in your database referring to Alice Glockam.

    – Jay
    Dec 29 '18 at 14:49













  • oh - and the data may be too deep so you may want to denormalize it. Lastly, PLEASE include structures as text, not images, in questions.

    – Jay
    Dec 29 '18 at 14:49

















You're going to run into a LOT of problems with this structure and it's unclear what 'filter' means in this use case. Are you asking if you can query for a node that contains a single employee? Or something else? As it is, you're getting all the child nodes within Customer so you could put each child node's data in an object, store those objects in an array and 'filter' them. But is that what you're asking how to do?

– Jay
Dec 29 '18 at 14:41







You're going to run into a LOT of problems with this structure and it's unclear what 'filter' means in this use case. Are you asking if you can query for a node that contains a single employee? Or something else? As it is, you're getting all the child nodes within Customer so you could put each child node's data in an object, store those objects in an array and 'filter' them. But is that what you're asking how to do?

– Jay
Dec 29 '18 at 14:41















There is some debate about using email addresses as keys but for me, I discourage it. See emails as keys are evil. Also, if Alice Glockam gets married and changes her name to Alice Smith; what are you going to do? Well, you'll have to find, delete and re-create every node in your database referring to Alice Glockam.

– Jay
Dec 29 '18 at 14:49







There is some debate about using email addresses as keys but for me, I discourage it. See emails as keys are evil. Also, if Alice Glockam gets married and changes her name to Alice Smith; what are you going to do? Well, you'll have to find, delete and re-create every node in your database referring to Alice Glockam.

– Jay
Dec 29 '18 at 14:49















oh - and the data may be too deep so you may want to denormalize it. Lastly, PLEASE include structures as text, not images, in questions.

– Jay
Dec 29 '18 at 14:49





oh - and the data may be too deep so you may want to denormalize it. Lastly, PLEASE include structures as text, not images, in questions.

– Jay
Dec 29 '18 at 14:49












1 Answer
1






active

oldest

votes


















0














Structure your database in this manner. Let me know if you need more assisstance here.



enter image description here






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',
    autoActivateHeartbeat: false,
    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%2f53969883%2ffilter-in-specific-firebase-structure%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









    0














    Structure your database in this manner. Let me know if you need more assisstance here.



    enter image description here






    share|improve this answer




























      0














      Structure your database in this manner. Let me know if you need more assisstance here.



      enter image description here






      share|improve this answer


























        0












        0








        0







        Structure your database in this manner. Let me know if you need more assisstance here.



        enter image description here






        share|improve this answer













        Structure your database in this manner. Let me know if you need more assisstance here.



        enter image description here







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 30 '18 at 6:49









        Yogesh TandelYogesh Tandel

        656711




        656711






























            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.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53969883%2ffilter-in-specific-firebase-structure%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

            Mossoró

            Can't read property showImagePicker of undefined in react native iOS

            Pushsharp Apns notification error: 'InvalidToken'