I'm trying to fetch all the guests of a party which is stored in an array called "PhoneNumbers." Each invite adds that persons phone number to the array. If there are more than 10 invites the app crashes because that is the Firestore limitation.
fileprivate func fetchGuests() {
print("hi hi")
guard !fetchedAllUsers, !fetchingMoreUsers else { return }
fetchingMoreUsers = true
tableView.reloadSections(IndexSet(integer: 1), with: .none)
let partyUID = self.party?.partyUID ?? ""
navigationItem.title = "\(party?.partyName ?? "") Guests"
Firestore.firestore().collection("parties").document(partyUID).getDocument { (snap, err) in
if let err = err {
print(err, "fook")
}
guard let partyDict = snap?.data() else {return}
let party = Party(dictionary: partyDict)
self.phoneNumbers = party.guestPhoneNumbers as! [String]
print(self.phoneNumbers)
var query: Query
if let lastFetchedNumber = self.lastFetchedNumber {
query = Firestore.firestore().collection("users").whereField("PhoneNumber", in: self.phoneNumbers).order(by: "Full Name").start(after: [lastFetchedNumber]).limit(to: 9)
} else {
query = Firestore.firestore().collection("users").whereField("PhoneNumber", in: self.phoneNumbers).order(by: "Full Name").limit(to: 9)
}
// Change logic where gender variable is just the where field firebase thing
query.getDocuments { (snapshot, err) in ......yadayadayada
Anyone have any ideas of how to work around the max 10 rule? Maybe should I add another array to the collection called PhoneNumbers2 for guests 9-18 and PhoneNumbers3 for 19-28?
Let me know if you have any ideas! (I can't add a new collection called guests because this app allows you to invite people you are not authenticated and I need to be able to query these numbers with out them having a UID if that makes sense)