第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

如何返回文檔索引名稱值

如何返回文檔索引名稱值

Go
拉風(fēng)的咖菲貓 2023-04-17 16:07:40
這是一個(gè) GoLang,F(xiàn)irebase AdminSDK 問題。此示例用于循環(huán)訪問 FireStore 數(shù)據(jù)庫中的所有文檔。我怎樣才能得到文檔名稱?換句話說:如果集合名稱是JohnyCollection,并且JohnyCollection有 20 個(gè)名為 ( Document1, Document2.... Document20) 的文檔,我如何在 golang 代碼中獲取文檔名稱?//========================================package mainimport (    "context"    "fmt"    "log"    "firebase.google.com/go"    "google.golang.org/api/iterator"    "google.golang.org/api/option")func check(e error) {    if e != nil {        panic(e)    }}func main() {    ctx := context.Background()    sa := option.WithCredentialsFile("./scai-qit-fb-adminsdk.json")    app, err := firebase.NewApp(ctx, nil, sa)    if err != nil {        log.Fatalf("error initializing app: %v\n", err)    }    client, err := app.Firestore(ctx)    if err != nil {        log.Fatal(err)    }    defer client.Close()    iter := client.Collection("COMPLEX_NONACS").Documents(ctx)    for {        doc, err := iter.Next()        if err == iterator.Done {            break        }        if err != nil {            log.Fatalf("Failed to iterate: %v", err)        }        //This part works.  WIll return a Map of each Document        fmt.Println("--------------------------/n")        fmt.Println(doc.Data())        //  This is the question.  How do I get the INDEX name of the Document?        //  something like...        fmt.Println(doc.Index_value_or_something_that_returns_IndexName())        //  for example...        // {        // "ABC":{"line1":"yabba dabba","line2":"dingo dong"},        // "DEF":{"line1":"hooty tooty","line2":"blah blah"}        // }        // How to just get the "ABC"  and "DEF"    }}
查看完整描述

1 回答

?
臨摹微笑

TA貢獻(xiàn)1982條經(jīng)驗(yàn) 獲得超2個(gè)贊

DocumentSnapshot您可以通過首先查找 來從 獲取文檔 ID?DocumentRef

?fmt.Println(doc.Ref.ID)


查看完整回答
反對(duì) 回復(fù) 2023-04-17
  • 1 回答
  • 0 關(guān)注
  • 113 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)