【发布时间】:2015-12-28 21:30:57
【问题描述】:
我的 keystone.js 项目中有以下模型:
/* Bankaccount.js */
var BankAccount = new keystone.List('BankAccount');
BankAccount.add({
owner: {type: Types.Relationship, ref: 'User', initial: true, index: true},
iban: { type: Types.Text, initial: true, index: true, required: true}
...
});
/* Transaction.js*/
var Transaction = new keystone.List('Transaction', {track:true});
Transaction.add({
customerBankAccount: {type: Types.Relationship, ref: 'BankAccount', initial: true, index: true, required: true },
merchantBankAccount: {type: Types.Relationship, ref: 'BankAccount', initial: true, index: true, required: true },
...
});
/* User.js */
var User = new keystone.List('User', {track:true});
User.add({
name: { type: Types.Name, initial: true, index: true},
email: { type: Types.Email, initial: true, index: true}
...
});
在注册我的用户模型之前,我想将它们链接回管理 UI。 对于银行帐户链接,我有:
// Linked Bank Accounts
User.relationship({
path: 'bankAccounts',
ref: 'BankAccount',
refPath: 'owner'
});
显示用户的银行账户。
但现在我想查看每个用户的交易。 有没有办法做到这一点?
类似:refPath: 'customerBankAccount.owner'(不起作用)
或者keystone不支持这个?
【问题讨论】:
标签: javascript node.js model keystonejs