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

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何使用 angular 查詢消防商店子集合?

如何使用 angular 查詢消防商店子集合?

嗶嗶one 2021-10-21 13:57:48
我正在嘗試在 ionic 4 應(yīng)用程序/角度應(yīng)用程序中查詢 Firestore 子集合。我的數(shù)據(jù)庫如下所示 people(id) ----> tasks(id){ description : this is a description about a cat,<br>  title: this is a cat <br>  category: cat } 我正在使用 Firestore 函數(shù)來查詢集合中的所有數(shù)據(jù)。這是 Firestore 函數(shù)的樣子:import * as functions from 'firebase-functions';import * as admin from 'firebase-admin'admin.initializeApp()    export const getFeed = functions.https.onCall(async (req,res) =>{    const docs = await     admin.firestore().collection('people').limit(5).get()    return docs.docs.map(doc => {    return {        postID: doc.id,        ...doc.data()       }    }) })打字稿 home.ts 文件如下所示:    const getFeed = this.aff.httpsCallable('getFeed')    this.posts = getFeed({}).subscribe(data=> {      console.log(data)      // this.posts = data        })    }我嘗試使用 array-contains 選項進(jìn)行查詢,但它不起作用。該數(shù)組在控制臺上顯示為空。   export const getFeed = functions.https.onCall(async (req,res) =>{    const docs = await     admin.firestore().collection('people').where("category",     "array-     contains", "cat").limit(5).get()    return docs.docs.map(doc => {    return {        postID: doc.id,        ...doc.data()       }    }) })
查看完整描述

2 回答

?
慕妹3242003

TA貢獻(xiàn)1824條經(jīng)驗 獲得超6個贊

您的問題不是很清楚,但看起來category您的數(shù)據(jù)庫字段實際上并不是列表類型字段。 array-contains僅當(dāng)值是一個列表時才有效,如果它只是一個字符串值,則無效。如果它只是一個字符串,則對其使用==過濾器。


查看完整回答
反對 回復(fù) 2021-10-21
?
郎朗坤

TA貢獻(xiàn)1921條經(jīng)驗 獲得超9個贊

我通過采用數(shù)組字段類型而不是子集合找到了解決方法。

這是我的代碼示例:

  var coll = this.firestore.collection('credentials', ref => ref.where('tags', 'array-contains-any', ['agile']).orderBy('shortName')); // selects part of collection where roomId = roomStripped, sorted by name

返回 coll.snapshotChanges();

我有一個名為憑據(jù)的主要集合,以及每個文檔中的標(biāo)簽列表。


查看完整回答
反對 回復(fù) 2021-10-21
  • 2 回答
  • 0 關(guān)注
  • 169 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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