【发布时间】:2018-05-26 17:11:40
【问题描述】:
我正在尝试将新文档发布到包含对现有文档的引用的集合中。
这是我的代码:
var admin = require('firebase-admin');
var serviceAccount = require('./serviceAccountKey.json');
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: 'https://DBURL.firebaseio.com'
});
var db = admin.firestore();
db.collection('myFunCollection').add({
someBool: false,
someNumber: 13.2,
video: 'videos/Izdm35CsW6kqv2UxZEX0',
user: 'users/pb7La4kzEaBow4iWvmxZ'
});
video 和 user 引用其他集合中的现有文档,但是当我运行此代码时,字段存储为字符串而不是引用。 The documentation notably does not describe how to do this.
如何将这些值作为参考发布?
【问题讨论】:
标签: node.js firebase google-cloud-firestore