我在下面的链接中提到了设置环回框架和创建简单的API
https://docs.strongloop.com/display/public/LB/Getting+started+with+LoopBack
但是当我尝试将API连接到datasource时,我收到了以下错误,但没有找到原因以及如何解决它。请有人帮我解决这个问题。
Error: Cannot migrate models not attached to this datasource: CoffeeShop
at /Users/emotian/Development/loopback-getting-started/node_modules/loopback-datasource-juggler/lib/datasource.js:822:14
at nextTickCallbackWith0Args (node.js:420:9)
at process._tickDomainCallback (node.js:390:13)
at process.fallback (/Users/emotian/Development/loopback-getting-started/node_modules/loopback/node_modules/continuation-local-storage/node_modules/async-listener/index.js:450:15)
at Function.Module.runMain (module.js:443:11)
at startup (node.js:139:18)
at node.js:968:3
答案 0 :(得分:0)
确保先添加数据源,然后安装连接器。
lb datasource mysqlDb
npm install --save loopback-connector-mysql
如果一切正确
,请检查server / datasources.json删除旧型号/ coffeeshop.js / json以防万一
然后运行
lb model
并选择新的数据源并添加所需的字段。