Error: Cannot call users.find(). The find method has not been setup. The PersistedModel has not been correctly attached to a DataSource!
at throwNotAttached (F:\PPL\Laundry\api.lb\node_modules\loopback\lib\persisted-model.js:71:11)
at Function.find (F:\PPL\Laundry\api.lb\node_modules\loopback\lib\persisted-model.js:259:5)
at module.exports (F:\PPL\Laundry\api.lb\common\models\users.js:11:11)
at F:\PPL\Laundry\api.lb\node_modules\loopback-boot\lib\executor.js:251:11
at Array.forEach (<anonymous>)
at defineModels (F:\PPL\Laundry\api.lb\node_modules\loopback-boot\lib\executor.js:229:23)
at setupModels (F:\PPL\Laundry\api.lb\node_modules\loopback-boot\lib\executor.js:197:3)
at execute (F:\PPL\Laundry\api.lb\node_modules\loopback-boot\lib\executor.js:40:3)
at bootLoopBackApp (F:\PPL\Laundry\api.lb\node_modules\loopback-boot\index.js:154:3)
at Object.<anonymous> (F:\PPL\Laundry\api.lb\server\server.js:23:1)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Function.Module.runMain (module.js:693:10)
答案 0 :(得分:0)
1)数据源:
{
"mysqlDB": {
"host": "localhost",
"port": 3306,
"url": "",
"database": "databse",
"password": "",
"name": "mysqlDB",
"user": "root",
"connector": "mysql"
}
}
MySQL默认为端口 3306
2)配置模型: model-config.json
"users": {
"dataSource": "mysqlDB",
"public": true
}
并删除模型
中的内部函数喜欢:
'use strict';
module.exports = function(Users) {
};