Polymerfire错误推送数据

时间:2017-01-06 19:47:29

标签: firebase firebase-realtime-database polymer polymerfire

我正在创建一个两个用户之间的合同,并按照下面的说明构建我的数据库。问题是我在与两个用户user_id:true创建合同时遇到问题。我不确定我是否采取了正确的方法。我遵循firebase文档并按照建议构建合同。

my-firebase
|
-contracts
  |- contract-id
    |- user_id: true
    |- user_id: true
    |- amount: 1000
    |- isactive: true
    |- started: 148314234733

我正在创建合同:

var contractDetails = {
 this.contractor:true,
 this.freelancer:true,
 amount: 1000,
 isactive: true,
 started: 'eee'
};

2 个答案:

答案 0 :(得分:0)

问题在于您使用this。如果您使用的是ES6,则可以使用computed properties

var contractDetails = {
  [this.contractor]: true,
  [this.freelancer]: true,
  amount: 1000,
  isactive: true
  started: this.timestamp
};

如果你不是,你可以做这样的事情,而不是:

var contractDetails = {
  amount: 1000,
  isactive: true
  started: this.timestamp
};
contractDetails[this.contractor] = true;
contractDetails[this.freelancer] = true;

答案 1 :(得分:0)

如何仅查询"contract"的{​​{1}} "isactive" - contract-id - )isactive:" true" _user.uid //组合数据以创建单个
- 查询 - )by-child =" [[queryHandler]]"

"user"

代码查询员工合同

- contract-id --) add property `user_uid_contractor` bind to `user.uid`<br>

    -contracts
      |- contract-id
        |- user_uid_freelancer: user.uid
        |- user_uid_contractor: user.uid
        |- amount: 1000
        |- isactive: "true"_user.uid // Combine data to create a single query.
        |- started: 148314234733