1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

firestoreでwhere(docid, 'in', 配列)がうまく動かなかった

Last updated at Posted at 2025-01-30

はじめに

firestoreからのデータ取得で少し時間がかかってしまったので記事にします

問題

以下のように配列に含まれるドキュメントidと一致するドキュメントを取得しようとするが取得できない。色々出力してみるとやはりここが原因そう。

query(コレクションのref, where('id', 'in', 配列))

解決策

whereで使ってる'id'はドキュメントのidをみているのではなくフィールドidをみてるみたいなのでここを直す必要がありました。

query(コレクションのref, where(documentId(), 'in', 配列))

注意点

inだと30件までしか取得できないみたいです。

1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?