从V0.12升级后,我在帆V1上遇到以下错误。
adapterMethodName: 'find',
modelIdentity: 'users',
raw:
{ UsageError: Could not run select() because of 2 problems:
------------------------------------------------------
• "datastore" is required, but it was not defined.
• "models" is required, but it was not defined.
------------------------------------------------------
Please adjust your usage and try again.
我在registerDatastore的node_modules / sails-postgresql / lib / adapter.js文件中添加了一些打印件,以查看我的设置在风帆中是否正确,模型和数据存储是否正确传递。然后我在find函数中添加了一个print,发现数据存储和modelDefinitions数组是空的。不知道应该在哪里填充它们,我可以自己分配它们,但我不想在node_modules中乱七八糟。我还尝试启动一个新的Sails V1应用程序,只是将我的更改迁移到它,结果相同。任何建议都会受到赞赏吗?
以下是一些特定于版本的详细信息 :
: node : v9.10.1
: engine (v8) : 6.2.414.46-node.23
: openssl : 1.0.2o
我的配置 :
sails.config.datastores :
default: {
adapter: 'sails-postgresql',
host: 'localhost',
port: 5432,
user: 'xxx',
password: 'xxx',
database: 'xxx',
ssl: false,
},
sails.config.globals :
module.exports.globals = {
_: require('@sailshq/lodash'),
async: require('async'),
models: true,
sails: true,
services: true,
adapters: true,
};
sails.config.env.development :
datastores: {
default: {
adapter: 'sails-postgresql',
host: 'localhost',
port: 5432,
user: 'xxx',
password: 'xxx',
database: 'xxx',
ssl: false,
},
},
启动时的一些详细打印:
verbo: grunt hook loaded successfully. (8ms)
: Loading hook: orm
: Loading the app's models and any custom adapters...
: Loading app models...
: Loading app adapters...
: Loading hook: sockets
verbo: Loading adapter (`sails-postgresql`) from this app's `node_modules/` directory...
: Starting ORM...
: Registering model `file_types` in Waterline
.
.
.
.
verbo: orm hook loaded successfully. (1036ms)
的package.json :
"dependencies": {
"@sailshq/connect-redis": "^3.2.1",
"@sailshq/lodash": "^3.10.3",
"@sailshq/socket.io-redis": "^5.2.0",
"ajv": "^6.4.0",
"async": "2.0.1",
"bcrypt": "^1.0.3",
"bugsnag": "^2.3.1",
"child_process": "^1.0.2",
"connect-redis": "^3.3.3",
"crypto": "^1.0.1",
"fs": "0.0.1-security",
"gifsicle": "^3.0.4",
"grunt": "1.0.1",
"jsonwebtoken": "^8.2.1",
"lodash": "^4.17.5",
"machinepack-emailaddresses": "^0.4.0",
"machinepack-redis": "^1.3.0",
"moment": "^2.22.0",
"passport": "^0.4.0",
"passport-facebook": "^2.1.1",
"passport-google-oauth": "^1.0.0",
"passport-local": "^1.0.0",
"request": "^2.85.0",
"rsmq": "^0.8.3",
"sails": "^1.0.0",
"sails-hook-grunt": "^3.1.0",
"sails-hook-orm": "^2.0.0-16",
"sails-hook-sockets": "^1.4.0",
"sails-postgresql": "^1.0.0",
"sharp": "^0.20.1",
"soap": "^0.24.0",
"socket.io-redis": "^5.2.0",
"ua-parser-js": "^0.7.17",
"uuid": "^3.2.1",
"uuid-validate": "0.0.2"
},
答案 0 :(得分:0)
在master分支上有一个针对此问题的修复程序,但它没有被标记并推送到npm(Bug 277)
显然,你的一个模型没有正确配置,而且由于这个bug,sails没有告诉你它是什么。
因此,要解决此问题,您应该从github url安装sails-postgresql
的固定提交,启动sails以查看问题所在,修复它,然后再次重新安装常规sails-postgresql版本。
您可以通过yarn安装固定主提交:
yarn add https://github.com/balderdashy/sails-postgresql.git#1ead0f407231aa2139a73fc65e5ded608418a92d --save
通过npm:
npm install https://github.com/balderdashy/sails-postgresql.git#1ead0f407231aa2139a73fc65e5ded608418a92d --save