gpt4 book ai didi

javascript - SailsJS 一对多自 v0.11.0 起不再工作

转载 作者:行者123 更新时间:2023-12-03 10:30:00 25 4
gpt4 key购买 nike

我目前正在开发 SailsJS 应用程序。我开始使用 0.10.5 版本,并实现了许多模型之间的继承。一切工作正常。

今天,我决定将我的 SailsJS 项目更新到版本 0.11.0。我读到最简单的方法是使用 npm 更新所有 SailsJS 文件,然后创建一个新项目,最后将所有模型、 Controller 等复制到新创建的项目中。这就是我到目前为止所做的。

现在,我每次尝试提升项目时都会遇到问题:

/usr/local/lib/node_modules/sails/node_modules/waterline/node_modules/waterline-schema/lib/waterline-schema/foreignKeys.js:82
throw new Error('Trying to access a collection ' + collection + ' that is
^
Error: Trying to access a collection series that is not defined.
at ForeignKeys.findPrimaryKey (/usr/local/lib/node_modules/sails/node_modules/waterline/node_modules/waterline-schema/lib/waterline-schema/foreignKeys.js:82:11)
at ForeignKeys.replaceKeys (/usr/local/lib/node_modules/sails/node_modules/waterline/node_modules/waterline-schema/lib/waterline-schema/foreignKeys.js:53:27)
at new ForeignKeys (/usr/local/lib/node_modules/sails/node_modules/waterline/node_modules/waterline-schema/lib/waterline-schema/foreignKeys.js:30:10)
at new module.exports (/usr/local/lib/node_modules/sails/node_modules/waterline/node_modules/waterline-schema/lib/waterline-schema.js:30:17)
at Waterline.initialize (/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline.js:107:17)
at buildORM (/usr/local/lib/node_modules/sails/lib/hooks/orm/build-orm.js:52:15)
at Array.async.auto.instantiatedCollections [as 1] (/usr/local/lib/node_modules/sails/lib/hooks/orm/index.js:203:11)
at listener (/usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:493:46)
at /usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:444:17
at Array.forEach (native)
at _each (/usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:46:24)
at Object.taskComplete (/usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:443:13)
at processImmediate [as _immediateCallback] (timers.js:345:15)

这是我的模型:

/api/services/OrthancObject.js

module.exports = {
attributes:
{
ID:
{
type: 'STRING',
primaryKey: true,
required: true
},
Type:
{
type: 'STRING',
required: true
},
MainDicomTags:
{
type: 'JSON',
required: true
}
}
}

/api/services/OrthancMutableObject.js

var OrthancObject = require('./OrthancObject.js');
module.exports = _.merge(_.cloneDeep(OrthancObject),
{
attributes:
{
IsStable:
{
type: 'BOOLEAN',
required: true
},
LastUpdate:
{
type: 'DATETIME',
required: true
}
}
});

/api/models/Patient.js

var OrthancMutableObject = require('../services/OrthancMutableObject.js');
module.exports = _.merge(_.cloneDeep(OrthancMutableObject),
{
attributes:
{
Studies:
{
collection: 'Study',
via: 'ParentPatient',
required: true
}
}
});

/api/models/Study.js

var OrthancMutableObject = require('../services/OrthancMutableObject.js');
module.exports = _.merge(_.cloneDeep(OrthancMutableObject),
{
attributes:
{
ParentPatient:
{
model: 'Patient',
required: true
},
Series:
{
collection: 'Series',
via: 'ParentStudy',
required: true
}
}
});

/api/models/Series.js

var OrthancMutableObject = require('../services/OrthancMutableObject.js');
module.exports = _.merge(_.cloneDeep(OrthancMutableObject),
{
attributes:
{
ExpectedNumberOfInstances:
{
type: 'INTEGER'
},
Instances:
{
collection: 'Instance',
via: 'ParentSeries',
required: true
},
ParentStudy:
{
model: 'Study',
required: true
},
Status:
{
type: 'STRING'
}
}
});

/api/models/Instance.js

var OrthancObject = require('../services/OrthancObject.js');
module.exports = _.merge(_.cloneDeep(OrthancObject),
{
attributes:
{
FileSize:
{
type: 'INTEGER',
required: true
},
FileUuid:
{
type: 'INTEGER',
required: true
},
IndexInSeries:
{
type: 'INTEGER',
required: true
},
ParentSeries:
{
model: 'Series'
}
}
});

你能解释一下我做错了什么吗?我不明白为什么它不再工作了(提醒:它在 v 0.10.5 中运行良好)。

感谢您的阅读,祝你有美好的一天:)

最佳答案

您的所有模型都应位于 api/models 中。无处。如果你只是遵循惯例,一切都会成功。

如果您有从中扩展的“基本”模型,如果您不希望在数据库中为它们创建表,只需将它们完全放在 api/ 之外。

关于javascript - SailsJS 一对多自 v0.11.0 起不再工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29257841/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com