В моем проекте Sails A у меня есть частичное определение модели:
Пользователь
module.exports = {
schema: true,
tableName: 'users',
primaryKey: 'id',
attributes: {
id: {
columnName: 'id',
unique: true,
type: 'number',
autoIncrement: true
},
service_id: {
type: 'number',
required: true
},
В другом проекте Sails B я определил остальную часть этой модели пользователя:
Пользователь
module.exports = {
schema: true,
tableName: 'users',
primaryKey: 'id',
attributes: {
id: {
columnName: 'id',
unique: true,
type: 'number',
autoIncrement: true
},
task_id: {
type: 'number',
required: true
},
и модель задачи
module.exports = {
schema: true,
tableName: 'tasks',
primaryKey: 'id',
attributes: {
id: {
columnName: 'id',
unique: true,
type: 'number',
autoIncrement: true
},
description: {
type: 'string',
required: true
},
Оба проекта A и B подключаются к одной и той же базе данных mysql.
I'm написание приемочного теста в проекте А, чтобы перечислить все задачи. Как я могу заполнить модель задачи в проекте A? Я получил следующую ошибку (которая очевидна):
Could not populate `tasks`. There is no attribute named `tasks` defined in this model.
Большое спасибо.