# Collection Group Query
- [Cloud Firestore ドキュメント ID でコレクショングループクエリ | リアキテク・ラボ Tech Blog](https://tech-blog.re-arc-lab.jp/posts/210105_firestore-collectiongroup-documentid/)
## Change Data Schema with Firefoo
Document ID をクエリに含めるのはつらいので、 Document ID を `doc_id` というフィールドに入れておく。
[Run JavaScript Query in Firestore - Firefoo](https://firefoo.app/docs/query-firestore-data/firestore-execute-javascript-query)
```js
async function run() {
const batch = db.batch();
const query = await db.collectionGroup("userBlocking").get();
console.log(query.size);
for (const doc of query.docs) {
console.log(doc.id);
batch.update(doc.ref, {doc_id: doc.id});
};
await batch.commit();
}
```