Meteor 服务器在 SimpleSchema autoValue 选项上崩溃
Meteor server is crashing on SimpleSchema autoValue option
我刚开始使用 MeteorJS 开发应用程序,当我在快速库存应用程序中收集某些项目时,这是一个问题。
这是错误:
/home/operador/.meteor/packages/meteor-tool/.1.1.10.1kpywhr++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:245
throw(ex);
^
Error: Invalid definition for active field.
at packages/aldeed_simple-schema/packages/aldeed_simple-schema.js:1328:1
at Function._.each._.forEach (packages/underscore/underscore.js:113:1)
at [object Object].SimpleSchema (packages/aldeed_simple-schema/packages/aldeed_simple-schema.js:1325:1)
at collections/assets.js:16:16
at /home/operador/fijos/.meteor/local/build/programs/server/app/collections/assets.js:64:4
at /home/operador/fijos/.meteor/local/build/programs/server/boot.js:242:10
at Array.forEach (native)
at Function._.each._.forEach (/home/operador/.meteor/packages/meteor-tool/.1.1.10.1kpywhr++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
at /home/operador/fijos/.meteor/local/build/programs/server/boot.js:137:5
Exited with code: 8
Your application is crashing. Waiting for file change.
这是 assets.js
:
Assets = new Mongo.Collection('assets')
Assets.allow({
insert: function(userId, userLvl, doc) {
return !!userId;
}
});
Brands = new SimpleSchema({
name: {
type: String,
label: "Brand"
}
});
Assetsschema = new SimpleSchema({
item: {
type: String,
label: "item"
},
year: {
type: Date,
label: "year"
},
model: {
type: String,
label: "model"
},
serialNumber: {
type: String,
label: "serialNumber"
},
brand: {
type: [Brands]
},
adquarance: {
type: Date,
label: "adquaranceDate"
},
codebar: {
type: String,
label: "codebar"
},
qrcode: {
type: String,
label: "QRcode"
},
active: {
type: Boolean,
label: "active",
autoValue: true
}
});
IDK 如何解决这个问题,我尝试更改模式的名称,但结果相同。
这是我的包裹清单:
kadira:flow-router
kadira:blaze-layout
erasaur:meteor-lodash
fortawesome:fontawesome
spiderable
fastclick
raix:handlebar-helpers
aldeed:collection2
aldeed:autoform
accounts-ui
accounts-password
matb33:bootstrap-glyphicons
zimme:active-route
gwendall:auth-client-callbacks
meteortoys:allthings
datariot:ganalytics
bootswatch:paper
numtel:mysql
hitchcott:qr-scanner
选项autoValue
允许您指定函数。因此,您的 Schema 结构应如下所示:
Assetsschema = new SimpleSchema({
item: {
type: String,
label: "item"
},
year: {
type: Date,
label: "year"
},
model: {
type: String,
label: "model"
},
serialNumber: {
type: String,
label: "serialNumber"
},
brand: {
type: [Brands]
},
adquarance: {
type: Date,
label: "adquaranceDate"
},
codebar: {
type: String,
label: "codebar"
},
qrcode: {
type: String,
label: "QRcode"
},
active: {
type: Boolean,
label: "active",
autoValue: function () {
return true;
}
}
});
我刚开始使用 MeteorJS 开发应用程序,当我在快速库存应用程序中收集某些项目时,这是一个问题。
这是错误:
/home/operador/.meteor/packages/meteor-tool/.1.1.10.1kpywhr++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:245
throw(ex);
^
Error: Invalid definition for active field.
at packages/aldeed_simple-schema/packages/aldeed_simple-schema.js:1328:1
at Function._.each._.forEach (packages/underscore/underscore.js:113:1)
at [object Object].SimpleSchema (packages/aldeed_simple-schema/packages/aldeed_simple-schema.js:1325:1)
at collections/assets.js:16:16
at /home/operador/fijos/.meteor/local/build/programs/server/app/collections/assets.js:64:4
at /home/operador/fijos/.meteor/local/build/programs/server/boot.js:242:10
at Array.forEach (native)
at Function._.each._.forEach (/home/operador/.meteor/packages/meteor-tool/.1.1.10.1kpywhr++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
at /home/operador/fijos/.meteor/local/build/programs/server/boot.js:137:5
Exited with code: 8
Your application is crashing. Waiting for file change.
这是 assets.js
:
Assets = new Mongo.Collection('assets')
Assets.allow({
insert: function(userId, userLvl, doc) {
return !!userId;
}
});
Brands = new SimpleSchema({
name: {
type: String,
label: "Brand"
}
});
Assetsschema = new SimpleSchema({
item: {
type: String,
label: "item"
},
year: {
type: Date,
label: "year"
},
model: {
type: String,
label: "model"
},
serialNumber: {
type: String,
label: "serialNumber"
},
brand: {
type: [Brands]
},
adquarance: {
type: Date,
label: "adquaranceDate"
},
codebar: {
type: String,
label: "codebar"
},
qrcode: {
type: String,
label: "QRcode"
},
active: {
type: Boolean,
label: "active",
autoValue: true
}
});
IDK 如何解决这个问题,我尝试更改模式的名称,但结果相同。
这是我的包裹清单:
kadira:flow-router
kadira:blaze-layout
erasaur:meteor-lodash
fortawesome:fontawesome
spiderable
fastclick
raix:handlebar-helpers
aldeed:collection2
aldeed:autoform
accounts-ui
accounts-password
matb33:bootstrap-glyphicons
zimme:active-route
gwendall:auth-client-callbacks
meteortoys:allthings
datariot:ganalytics
bootswatch:paper
numtel:mysql
hitchcott:qr-scanner
选项autoValue
允许您指定函数。因此,您的 Schema 结构应如下所示:
Assetsschema = new SimpleSchema({
item: {
type: String,
label: "item"
},
year: {
type: Date,
label: "year"
},
model: {
type: String,
label: "model"
},
serialNumber: {
type: String,
label: "serialNumber"
},
brand: {
type: [Brands]
},
adquarance: {
type: Date,
label: "adquaranceDate"
},
codebar: {
type: String,
label: "codebar"
},
qrcode: {
type: String,
label: "QRcode"
},
active: {
type: Boolean,
label: "active",
autoValue: function () {
return true;
}
}
});