1
如何通過由onCreate()雲觸發器觸發的雲功能爲新創建的文檔添加新屬性。 是否可以使用相同的方法在客戶端以及服務器端升級文檔,即在雲功能中?Google Cloud Firestore觸發器
如何通過由onCreate()雲觸發器觸發的雲功能爲新創建的文檔添加新屬性。 是否可以使用相同的方法在客戶端以及服務器端升級文檔,即在雲功能中?Google Cloud Firestore觸發器
每the docs,您可以使用event.data.ref
執行操作:
exports.addUserProperty = functions.firestore
.document('users/{userId}')
.onCreate(event => {
// Get an object representing the document
// e.g. {'name': 'Marie', 'age': 66}
var data = event.data.data();
// add a new property to the user object, write it to Firestore
return event.data.ref.update({
"born": "Poland"
});
});
我選擇了自動生成的ID爲documents.Then如何添加路徑爲特定的文件,因爲我不知道文檔ID –
這是通配符:「{wildcardId}」的用途。它將捕獲該位置的所有更改。 –