我在Schema for Collection1中定义了Autovalue。
此autvalue只能由Admin设置,例如:
userId: {
type: String,
optional: true,
autoValue: function() {
if (!this.isSet) {
return Meteor.userId();
} elseif !Meteor.user().isAdmin {
this.unset();
}
},
autoform: {
type: 'hidden'
},
},
当我创建灯具时,我需要强制设置userId,因此我尝试模拟我在server/fixtures.js
Meteor.setUserId(admins.kostya.id);
不幸的是我收到了这个错误:
20150829-15:45:26.819(-4)? (STDERR) /home/kostya/.meteor/packages/meteor-tool/.1.1.4.1bxqrno++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:245
W20150829-15:45:26.819(-4)? (STDERR) throw(ex);
W20150829-15:45:26.820(-4)? (STDERR) ^
W20150829-15:45:26.823(-4)? (STDERR) TypeError: Object #<Object> has no method 'setUserId'
W20150829-15:45:26.823(-4)? (STDERR) at app/server/fixtures.js:58:10
W20150829-15:45:26.823(-4)? (STDERR) at app/server/fixtures.js:246:3
W20150829-15:45:26.823(-4)? (STDERR) at /home/kostya/Application/myProject/.meteor/local/build/programs/server/boot.js:222:10
W20150829-15:45:26.824(-4)? (STDERR) at Array.forEach (native)
W20150829-15:45:26.824(-4)? (STDERR) at Function._.each._.forEach (/home/kostya/.meteor/packages/meteor-tool/.1.1.4.1bxqrno++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
W20150829-15:45:26.824(-4)? (STDERR) at /home/kostya/Application/myProject/.meteor/local/build/programs/server/boot.js:117:5
=> Exited with code: 8
任何线索?