LoginSignup
3
3

More than 3 years have passed since last update.

SwiftとFirestoreで部分一致させる

Last updated at Posted at 2021-04-18

はじめに

Swiftを使ってCloud FirestoreのデータをLike検索したので、メモのために残しておきます。

やり方

こんな感じでoder、start、endを使えばいけます!
「searchText」に部分一致する対象を検索しています。
swiftでは"\u{f8ff}"の様に中かっこで囲むのが肝みたいです。

sample
        Firestore.firestore().collection("users").order(by: "name").start(at: [searchText]).end(at: [searchText + "\u{f8ff}"]).getDocuments(){ (querySnapshot, error) in
            if let querySnapshot = querySnapshot {
                print("成功")
            } else if let error = error {
                print("失敗")
            }
        }

参考文献

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3