我正在使用来自保龄球的防火/聚合火包安装火柴/聚合火
如何在触发方法之后在数据库中创建一些数据?
文档标记看起来将显示和更新数据。我想,当用户注册时,创建一些数据供用户使用。
app.signInAnonymously = function() {
this.error = null;
this.$.auth.signInAnonymously();
// add default data for the user template
};如何使用默认的set()或像普通SDK这样的push方法?
我如何在来自JavaScript的事件中调用这一点?
当试图将路径绑定到我的文档时,如
<firebase-document
path="/"
data="{{firebaseData}}">
</firebase-document>
{{firebaseData}}数据不会显示,但我有身份验证工作。
发布于 2016-06-08 22:13:57
实际上,您可以直接使用firebase,因为firebase-auth已经包含了它,但是如果您想保持基于元素的功能,可以这样做:
将空firebase-document添加到template中
<firebase-document id="mydoc"></firebase-document>然后在元素中调用它的save函数
app.signInAnonymously = function() {
this.error = null;
this.$.auth.signInAnonymously();
// add default data for the user template
//set path to null somewhere to avoid overwriting data, I recommend doing it here since save's path update is lazy
this.$.mydoc.path = null;
//set data to the value to set/push
this.$.mydoc.data = {/*your data*/};
//call save, if the second parameter is falsey it'll call push to the first parameter if it's truthy it'll set the data to firstparam/secondparam
this.$.mydoc.save('path/to/users', userid);
};至于使用firebase-document获取数据,请检查您的数据库和安全规则中是否确实有数据,如果您仍然看不到您的数据,那么它可能与this issue有关,请记住polymerfire仍然处于预发布状态。
https://stackoverflow.com/questions/37711115
复制相似问题