0

我正在创建两个用户之间的合同并按如下所述构建我的数据库。问题是我在与两个用户创建合同时遇到问题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'
};
4

2 回答 2

0

How to query only "contract"that are "isactive"for a "user"
- contract-id --) isactive: "true"_user.uid // 合并数据以创建单个
- 查询 --) order-by-child="[[queryHandler]]"

- 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

代码查询员工合同

  <firebase-query
   app-name="vida"
   path="/contracts"
   data="{{mycontracts}}"
   order-by-child=""true_"[[queryHandler]]"
   equal-to="[[user.uid]]"></firebase-query>

       properties:{
       queryHandler // computed value that build the path
       }
于 2017-01-07T03:29:56.153 回答
0

问题是您使用this. 如果您使用的是 ES6,则可以使用计算属性

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;
于 2017-01-06T21:44:14.763 回答