簡體   English   中英

Firestore 查詢文檔以特定字符開頭

[英]Firestore query documents startsWith a specific character

是否可以查詢 firestore 集合以獲取所有以特定字符開頭的文檔? 例如,如果我有一個集合“Items”,其中包含:

在此處輸入圖像描述

例如,我只想以 II 開頭的文檔不知道如何修改查詢,方法 charAt[0] 無法識別:

return itemRef
      .doc(this.itemsId)
      .collection("october")
      .where(firebase.firestore.FieldPath.documentId().charAt[0], "==", randomChar)

從我的頭頂,如果對字母“I”感興趣:

var lower = 'I';
var upper = String.fromCharCode(lower.codeUnitAt(0) + 1);

itemRef
      .doc(this.itemsId)
      .collection("october")
      .where(firebase.firestore.FieldPath.documentId() ">=", lower)
      .where(firebase.firestore.FieldPath.documentId() "<", upper)

不確定,在字母 Z 的情況下會發生什么。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM