且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 Cloud Firestore 文档中列出子集合

更新时间:2023-02-14 09:41:59

在 Node.js 中,您将使用 'ListCollectionIds' 方法

In Node.js you'll be after the 'ListCollectionIds' method

var firestore = require('firestore.v1beta1');

var client = firestore.v1beta1({
  // optional auth parameters.
});

// Iterate over all elements.
var formattedParent = client.anyPathPath("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");

client.listCollectionIds({parent: formattedParent}).then(function(responses) {
    var resources = responses[0];
    for (var i = 0; i < resources.length; ++i) {
        // doThingsWith(resources[i])
    }
})
.catch(function(err) {
    console.error(err);
});

客户端 SDK(Web、iOS、Android)目前不支持此功能.

This is not currently supported in the client SDKs (Web, iOS, Android).