我在 Sails 中声明了两个模型,我正在使用 Waterline-Orientdb 适配器,但不知道如何通过双向边缘连接它们
问题模型
var Waterline = require('waterline');
module.exports = Waterline.Collection.extend({
tableName: 'questionsTable',
identity: 'questions',
connection: 'associations',
attributes: {
id: { type: 'string', primaryKey: true, columnName: '@rid'},
question : { type: 'string'},
user: { model: "User", required: true },
answerOptions: {type: 'json'},
imagefile: {type:'string'},
answers: {
collection: 'answer',
via: 'questions',
dominant:true
}
}
});
答案模型
var Waterline = require('waterline');
module.exports = Waterline.Collection.extend({
tableName: 'answerTable',
identity: 'answer',
connection: 'associations',
attributes: {
id: {
type: 'string',
primaryKey: true,
columnName: '@rid'
},
Answer: {
type: 'string'
},
questions: {
collection: 'questions',
via: 'answer'
}
}
});
我希望能够在两个模型之间创造优势。用户创建一个问题,然后用户可以发布回复。