Я пытаюсь работать с Модели с ассоциациями. У меня есть три модели:Как обновить модель с ассоциациями в SailJS
PosProductCategory.js
module.exports = {
schema : true,
attributes: {
name : {type : 'string', required : true },
desc : {type : 'text', required : true },
// assets
products : { collection : 'PosProduct', via : 'category' },
productsCustomize : { collection : 'PosCustomProduct', via : 'category' },
display : { model : 'CmsProductCategory' },
// available spec & template attribute
availableSpecification : { type : 'array' },
templateAttribute : { type : 'array' },
// store referrer
store : { model : 'SystemStore' }
}
};
PosProduct.js
module.exports = {
schema : true,
attributes: {
name : { type : 'string', required : true },
desc : { type : 'text' },
basePrice : { type : 'integer' , required : true },
// category
category : { model : 'PosProductCategory'},
// tags
// { "text": {string} }
tags : { collection : 'PosProductTag', via : 'products', dominant: true},
// attributes
attributes : { type : 'object' },
// specification
specification : { type : 'object' },
// materials (donwlodable material/attachment)
// { name : {string}, file: {string}, notes : {text} }
materials : {type : 'array'},
// publishment
published : { type : 'boolean', defaultsTo: false },
// assets
display : { model : 'CmsProduct' },
// store referrer
store : { model : 'SystemStore' }
}
};
PosCustomProduct.js
module.exports = {
schema : true,
attributes: {
name : { type : 'string', required : true },
basePrice : { type : 'integer' , required : true },
//category
category : { model : 'PosProductCategory'},
//variant
attributes : { type : 'object' },
//gambar setiap sisi
materials : { type : 'object' },
// publishment
published : { type : 'boolean', defaultsTo: false },
// assets
display : { model : 'CmsCustomProduct' },
// store referrer
store : { model : 'SystemStore' }
}
Если я запускаю с помощью парусов, то лифт, у меня есть ошибка Ошибка: попытка связать атрибут коллекции с моделью, у которой нет ключа Foregn. категория poscustomproduct пытается ссылаться на внешний ключ в poscustomproduct. Я пытался исправить его, но у него все еще была ошибка. Итак, как исправить мою модель?