Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?

Firebase / Firestore のTimestamp の比較メソッドisEqualとcompare

More than 1 year has passed since last update.

FirestoreにてTimestamp型を使用していますが、2つのTimestampの比較方法がわからなかったので今回調べました。

isEqual(object:)

インスタンスが同一かどうか

let now = Timestamp()
now.isEqual(now) // -> true

compare(object:)

2つのTimestampが同一時間か、もしくは以上・以下か

let now = Timestamp()
now.compare(now) // -> `.orderedSame`

compare(object:)メソッドによる結果

// 左は右よりも小さい
case orderedAscending
// 左は右よりも大きい
case orderedDescending
// 左右が同じ
case orderedSame

以上、備忘録です。

Riscait
FlutterとiOSネイティブのアプリ開発者です。 https://apps.apple.com/jp/developer/id914329387
https://nerco.jp
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away