Treating lowercase and uppercase as the same in database search [duplicate]












0
















This question already has an answer here:




  • Cloud Firestore Case Insensitive Sorting Using Query

    2 answers




I have a firebase application and I want to be able to search for user but the problem I am having is if the database value is hello, if user inputs hello in the search bar it returns true but if Hello, it returns false. I want to be able to treat lowercase and uppercase as the same so even if a user typed hElLo, it returns true. below is my code.



func fsFindUser(q user: String, completion: @escaping CompletionHandler) {

let userRef = fsRef.collection(USERS_REF)
let query = userRef.whereField("user", isEqualTo: user)

query.addSnapshotListener { (snapshot, error) in

if let error = error {
print("Error getting document: (error)")
} else if (snapshot?.isEmpty)! {

completion(false)

} else {
completion(true)

}
}
}









share|improve this question















marked as duplicate by Frank van Puffelen firebase
Users with the  firebase badge can single-handedly close firebase questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 25 '18 at 15:25


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.























    0
















    This question already has an answer here:




    • Cloud Firestore Case Insensitive Sorting Using Query

      2 answers




    I have a firebase application and I want to be able to search for user but the problem I am having is if the database value is hello, if user inputs hello in the search bar it returns true but if Hello, it returns false. I want to be able to treat lowercase and uppercase as the same so even if a user typed hElLo, it returns true. below is my code.



    func fsFindUser(q user: String, completion: @escaping CompletionHandler) {

    let userRef = fsRef.collection(USERS_REF)
    let query = userRef.whereField("user", isEqualTo: user)

    query.addSnapshotListener { (snapshot, error) in

    if let error = error {
    print("Error getting document: (error)")
    } else if (snapshot?.isEmpty)! {

    completion(false)

    } else {
    completion(true)

    }
    }
    }









    share|improve this question















    marked as duplicate by Frank van Puffelen firebase
    Users with the  firebase badge can single-handedly close firebase questions as duplicates and reopen them as needed.

    StackExchange.ready(function() {
    if (StackExchange.options.isMobile) return;

    $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
    var $hover = $(this).addClass('hover-bound'),
    $msg = $hover.siblings('.dupe-hammer-message');

    $hover.hover(
    function() {
    $hover.showInfoMessage('', {
    messageElement: $msg.clone().show(),
    transient: false,
    position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
    dismissable: false,
    relativeToBody: true
    });
    },
    function() {
    StackExchange.helpers.removeMessages();
    }
    );
    });
    });
    Nov 25 '18 at 15:25


    This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.





















      0












      0








      0









      This question already has an answer here:




      • Cloud Firestore Case Insensitive Sorting Using Query

        2 answers




      I have a firebase application and I want to be able to search for user but the problem I am having is if the database value is hello, if user inputs hello in the search bar it returns true but if Hello, it returns false. I want to be able to treat lowercase and uppercase as the same so even if a user typed hElLo, it returns true. below is my code.



      func fsFindUser(q user: String, completion: @escaping CompletionHandler) {

      let userRef = fsRef.collection(USERS_REF)
      let query = userRef.whereField("user", isEqualTo: user)

      query.addSnapshotListener { (snapshot, error) in

      if let error = error {
      print("Error getting document: (error)")
      } else if (snapshot?.isEmpty)! {

      completion(false)

      } else {
      completion(true)

      }
      }
      }









      share|improve this question

















      This question already has an answer here:




      • Cloud Firestore Case Insensitive Sorting Using Query

        2 answers




      I have a firebase application and I want to be able to search for user but the problem I am having is if the database value is hello, if user inputs hello in the search bar it returns true but if Hello, it returns false. I want to be able to treat lowercase and uppercase as the same so even if a user typed hElLo, it returns true. below is my code.



      func fsFindUser(q user: String, completion: @escaping CompletionHandler) {

      let userRef = fsRef.collection(USERS_REF)
      let query = userRef.whereField("user", isEqualTo: user)

      query.addSnapshotListener { (snapshot, error) in

      if let error = error {
      print("Error getting document: (error)")
      } else if (snapshot?.isEmpty)! {

      completion(false)

      } else {
      completion(true)

      }
      }
      }




      This question already has an answer here:




      • Cloud Firestore Case Insensitive Sorting Using Query

        2 answers








      swift firebase google-cloud-firestore






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 25 '18 at 12:13









      Doug Stevenson

      79.8k996114




      79.8k996114










      asked Nov 25 '18 at 11:03









      KingKing

      154220




      154220




      marked as duplicate by Frank van Puffelen firebase
      Users with the  firebase badge can single-handedly close firebase questions as duplicates and reopen them as needed.

      StackExchange.ready(function() {
      if (StackExchange.options.isMobile) return;

      $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
      var $hover = $(this).addClass('hover-bound'),
      $msg = $hover.siblings('.dupe-hammer-message');

      $hover.hover(
      function() {
      $hover.showInfoMessage('', {
      messageElement: $msg.clone().show(),
      transient: false,
      position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
      dismissable: false,
      relativeToBody: true
      });
      },
      function() {
      StackExchange.helpers.removeMessages();
      }
      );
      });
      });
      Nov 25 '18 at 15:25


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









      marked as duplicate by Frank van Puffelen firebase
      Users with the  firebase badge can single-handedly close firebase questions as duplicates and reopen them as needed.

      StackExchange.ready(function() {
      if (StackExchange.options.isMobile) return;

      $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
      var $hover = $(this).addClass('hover-bound'),
      $msg = $hover.siblings('.dupe-hammer-message');

      $hover.hover(
      function() {
      $hover.showInfoMessage('', {
      messageElement: $msg.clone().show(),
      transient: false,
      position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
      dismissable: false,
      relativeToBody: true
      });
      },
      function() {
      StackExchange.helpers.removeMessages();
      }
      );
      });
      });
      Nov 25 '18 at 15:25


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


























          1 Answer
          1






          active

          oldest

          votes


















          1














          The answer is you store two sets of data in your node; one used for queries that's lowercased and the other used for display



          users
          uid_0
          queryable: "mcdonald"
          display: "McDonald"
          uid_1
          queryable: "van winkle"
          display: "Van Winkle"





          share|improve this answer


























          • this makes a lot of sense. so I just have to search with queryable

            – King
            Nov 25 '18 at 13:52


















          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          The answer is you store two sets of data in your node; one used for queries that's lowercased and the other used for display



          users
          uid_0
          queryable: "mcdonald"
          display: "McDonald"
          uid_1
          queryable: "van winkle"
          display: "Van Winkle"





          share|improve this answer


























          • this makes a lot of sense. so I just have to search with queryable

            – King
            Nov 25 '18 at 13:52
















          1














          The answer is you store two sets of data in your node; one used for queries that's lowercased and the other used for display



          users
          uid_0
          queryable: "mcdonald"
          display: "McDonald"
          uid_1
          queryable: "van winkle"
          display: "Van Winkle"





          share|improve this answer


























          • this makes a lot of sense. so I just have to search with queryable

            – King
            Nov 25 '18 at 13:52














          1












          1








          1







          The answer is you store two sets of data in your node; one used for queries that's lowercased and the other used for display



          users
          uid_0
          queryable: "mcdonald"
          display: "McDonald"
          uid_1
          queryable: "van winkle"
          display: "Van Winkle"





          share|improve this answer















          The answer is you store two sets of data in your node; one used for queries that's lowercased and the other used for display



          users
          uid_0
          queryable: "mcdonald"
          display: "McDonald"
          uid_1
          queryable: "van winkle"
          display: "Van Winkle"






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 25 '18 at 14:02

























          answered Nov 25 '18 at 13:49









          JayJay

          19.1k43152




          19.1k43152













          • this makes a lot of sense. so I just have to search with queryable

            – King
            Nov 25 '18 at 13:52



















          • this makes a lot of sense. so I just have to search with queryable

            – King
            Nov 25 '18 at 13:52

















          this makes a lot of sense. so I just have to search with queryable

          – King
          Nov 25 '18 at 13:52





          this makes a lot of sense. so I just have to search with queryable

          – King
          Nov 25 '18 at 13:52





          Popular posts from this blog

          Costa Masnaga

          Fotorealismo

          Sidney Franklin