目前,我使用以下查询来查询我的firestore数据库: def get_db_from_cloud(self):
"""
gets all the info in the db back to the flask app
as a dictonary ready to be cached
"""
docs = self.db.collection(self.collection_name).stream()
docs_dict = {}
for doc in docs:
我从Firestore数据库获得一个集合,并将文档值添加到JS中的数组中:
var data = myCollection();
var myArray = [];
data.forEach(function(data) {
var splitPath = data.name.split('/');
var documentId = splitPath[splitPath.length - 1];
var name = data.fields.name ? data.fields.name.stringValue : '';
我正在尝试通过单击事件来删除firestore文档的方法。 这是我到目前为止所拥有的。x是我从firestore获得的文档id。但是,如何根据页面中显示的内容动态更改ID呢?以便用户可以删除他们想要内容。 var deleteContent = document.getElementById('delete');
deleteContent.addEventListener('click', function(e) {
// get current document ID
x = 'poOjcQce2iiKzp2FaFVA'
这是我想要完成的事情:我正在建立一个网络商店。网上商店有一个反应前端。前端从Firestore获取,并在商店页面上显示集合数组中的所有项。用户在商店页面上选择一个项目。对我的和服务器进行项字段的签出会话。用户转到Stripe结账表单,并在付款完成后被Stripe发送回我的前端。我在服务器上侦听该事件,然后想要更新Firestore中项目的quantity字段。
但是,如何查询此项的Firestore呢?是否有一种方法只使用这个id字段(或name字段)来查询Firestore?有些东西像:
db
.collection('collections')
我正在尝试从firestore获取集合数据,并将数据保存为JSON格式,现在我可以做到这两点,每次有更改我的列表正在更新,问题是它没有显示ID字段,所以所有发生更改的集合都保存没有任何文档ID。我尝试了附加帖子中建议的一些解决方案,但根本没有效果。任何对我有帮助的建议或想法。 Get document id firestore angular How to get firestore document ID from document snapshot? const fs =require('fs');
const db = admin.firestore();
var No
所以我试着从火力基地的一个文档中得到一些信息。我做了好几次了,但这次我犯了一个奇怪的错误。
Error: Assertion failed: file:///E:/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore_platform_interface-2.2.1/lib/src/platform_interface/platform_interface_document_snapshot.dart:69:12
field is String || field is FieldPath
"Supported [field
如果文档ID不存在,我想将数据添加到firestore数据库中。到目前为止,我已经尝试了: // varuId == the ID that is set to the document when created
var firestore = Firestore.instance;
if (firestore.collection("posts").document().documentID == varuId) {
return AlertDialog(
content: T
我看到,要在安全规则中获取文档字段,必须使用get。下面的示例显示了在users集合中获取某个文档的“admin”字段。如果我想获得另一个字段,我是否需要执行另一个get请求,或者我可以只执行一个get请求并获得文档中我需要的所有字段。
这里是我在文档中提到的例子。
service cloud.firestore {
match /databases/{database}/documents {
match /cities/{city} {
// Make sure a 'users' document exists f