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

More than 5 years have passed since last update.

【Firebase】FirestoreのSQLでドキュメントIDによりクエリする方法

Posted at

通常のクエリ

カラムに格納されている値でクエリするときは、以下のようなイメージ
var citiesRef = db.collection("cities");
そもそもNoSqlなので、「select id from ...」みたいな方法ではありません。

ドキュメントIDで取得する

こんな感じで取得できます。
var citiesRef = db.collection("cities").doc("Is3jt6EuiFgy53iigCzX");

取得後

  db.collection("cities")
    .doc("Is3jt6EuiFgy53iigCzX")
    .get()
    .then(querySnapshot => {
      console.log(`${querySnapshot.Location} => ${querySnapshot.data().Country}`);
    });

取得後、欲しい値を上記のような感じで取ってこれます。

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