在这种情况下,您需要使用文档ID作为条件。使用where方法来筛选具有特定文档ID的文档。例如,以下代码将选择具有特定文档ID的用户文档: 代码语言:txt 复制 var query = usersRef.where(firebase.firestore.FieldPath.documentId(), "==", "specific_document_id");...
log('No such document!'); } }).catch((error) => { console.log('Error getting document:', error); }); 方法2:使用where()方法和==操作符 如果您想要根据某个字段的值来查找文档,可以使用where()方法和==操作符。但是,请注意,Firestore的查询是基于索引的,因此这种方法可能不如直接使用文档引用高效...
即:在“TopCollection/document_this/NextCollection/document_that/Travesty/document_Id_I_want”中查找文档 使用集合组“Travesty” db.collectionGroup("Travesty") .where(firebase.firestore.FieldPath.documentId(), '==', "document_id_I_want") … 会 失败,但是… db.collectionGroup("Travesty") .where...
.where("hsc", "==", "1") .get() .then((doc) => { if (!doc.exists) { return response.status(404).json( { error: 'Todo not found' }); } TodoData = doc.data(); TodoData.todoId = doc.id; return response.json(TodoData); }) .catch((err) => { console.error(err); re...
UUIDs (document) // Android int currentPhotoNumber = 13; firebaseFirestore.collection("photos").whereEqualTo("photo_id", currentPhotoNumber).get().addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() { @Override public void onComplete(@NonNull Task<QuerySnapshot> task) { ...
这是专门针对服务器SDK的 更新: Cloud Firestore 现在支持 IN 查询! myCollection.where(firestore.FieldPath.documentId(), 'in', ["123","456","789"]) 原文由 Nick Franceschina 发布,翻译遵循 CC BY-SA 4.0 许可协议 有用 回复 查看全部 2 个回答 ...
带有 != 子句的查询。在这种情况下,您应该将查询拆分为大于查询和小于查询。例如,虽然查询子句 where(...
.where('members', 'array-contains', userID) .orderBy('lastLoggedAt', 'desc') .limit(2) .startAfter(startAfterVar) .onSnapshot(snapshot => { // Do something to store }); 免责声明:与实时侦听器进行分页很困难。 你所描述的是预期的行为。从该数据集开始: ...
I have the same issue. It seems findByXxxIn() where Xxx is not @DocumentId (so you have to assign an own identifier like UUID) is a workaround albeit a shitty one as FireStore probably uses the documentId for indexing and this might affect performance or costs (?)...
where clausesUse standard firestore operations ==, >, >=, <, <=, !=, in, not-in, array-contains, array-contains-anyconst users = await User.findAll({ where: { years: { '>': 10, '<=': 40, }, }, })id clausesUse id clauses to filter by documentIdconst users = await ...