Treating lowercase and uppercase as the same in database search [duplicate]
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)
}
}
}
swift firebase google-cloud-firestore
marked as duplicate by Frank van Puffelen
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.
add a comment |
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)
}
}
}
swift firebase google-cloud-firestore
marked as duplicate by Frank van Puffelen
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.
add a comment |
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)
}
}
}
swift firebase google-cloud-firestore
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
swift firebase google-cloud-firestore
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
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
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.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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"
this makes a lot of sense. so I just have to search with queryable
– King
Nov 25 '18 at 13:52
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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"
this makes a lot of sense. so I just have to search with queryable
– King
Nov 25 '18 at 13:52
add a comment |
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"
this makes a lot of sense. so I just have to search with queryable
– King
Nov 25 '18 at 13:52
add a comment |
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"
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"
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
add a comment |
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
add a comment |