我正在将timestamp mixin添加到我的模型中,但是当我运行时
node .
我收到此错误:
/home/ubuntu/bike/node_modules/loopback/node_modules/loopback-datasource-juggler/lib/mixins.js:50
throw new Error(errMsg);
^
Error: Model "BalanceHistory" uses unknown mixin: Timestamp
at MixinProvider.applyMixin (/home/ubuntu/bike/node_modules/loopback/node_modules/loopback-datasource-juggler/lib/mixins.js:50:13)
at ModelBuilder.defineClass [as define] (/home/ubuntu/bike/node_modules/loopback/node_modules/loopback-datasource-juggler/lib/model-builder.js:649:27)
at Function.ModelClass.extend (/home/ubuntu/bike/node_modules/loopback/node_modules/loopback-datasource-juggler/lib/model-builder.js:447:33)
at Registry.createModel (/home/ubuntu/bike/node_modules/loopback/lib/registry.js:122:25)
at /home/ubuntu/bike/node_modules/loopback-boot/lib/executor.js:245:24
at Array.forEach (native)
at defineModels (/home/ubuntu/bike/node_modules/loopback-boot/lib/executor.js:229:23)
at setupModels (/home/ubuntu/bike/node_modules/loopback-boot/lib/executor.js:197:3)
at execute (/home/ubuntu/bike/node_modules/loopback-boot/lib/executor.js:40:3)
at bootLoopBackApp (/home/ubuntu/bike/node_modules/loopback-boot/index.js:154:3)
at Object.<anonymous> (/home/ubuntu/bike/server/server.js:23:1)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:441:10)
at startup (node.js:140:18)
at node.js:1043:3
在我的model-config.json中,我已经改为:
"_meta": {
"sources": [
"loopback/common/models",
"loopback/server/models",
"../common/models",
"./models"
],
"mixins": [
"loopback/common/mixins",
"../node_modules/loopback-ds-timestamp-mixin",
"../common/mixins"
]}
并且很奇怪,即使我已经改为../node_modules/loopback-ds-timestamp-mixin,它仍然会加载node_modules / loopback / node_modules / loopback-datasource-juggler / lib / mixins。这不是我想要的js。有谁知道如何正确设置?
答案 0 :(得分:3)
loopback-ds-timestamp-mixin
mixin将自己定义为TimeStamp
;使用大写&#34; S&#34; ,以便在BalanceHistory
JSON定义文件的mixins对象中以这种方式定义。
BTW,node_modules/loopback/node_modules/loopback-datasource-juggler/lib/mixins.js
是抛出异常的文件,而不是环回寻找你的mixins的地方。