simpl-schema: Problem when attach on "aldeed:collection2-core"
I tried aldeed:collection2-core, simpl-schema2, but have problem on Posts.attachSchema(Posts.schema)
import {Mongo} from 'meteor/mongo';
import SimpleSchema2 from 'simpl-schema';
// import { SimpleSchema } from 'meteor/aldeed:simple-schema';
const Posts = new Mongo.Collection('posts');
Posts.schema = new SimpleSchema2({
createdDate: {
type: Date,
},
title: {
type: String,
},
body: {
type: String,
},
});
Posts.attachSchema(Posts.schema);
export default Posts;
It show
Error: Invalid definition for pick field.
W20170329-10:07:49.304(7)? (STDERR) at packages/aldeed_simple-schema.js:1429:13
W20170329-10:07:49.304(7)? (STDERR) at Function._.each._.forEach (packages/underscore.js:147:22)
W20170329-10:07:49.304(7)? (STDERR) at [object Object].SimpleSchema (packages/aldeed_simple-schema.js:1426:5)
W20170329-10:07:49.304(7)? (STDERR) at [object Object].c2AttachSchema [as attachSchema] (packages/aldeed_collection2-core.js:62:10)
W20170329-10:07:49.305(7)? (STDERR) at meteorInstall.imports.api.posts.posts.js (imports/api/posts/posts.js:27:16)
W20170329-10:07:49.305(7)? (STDERR) at fileEvaluate (packages/modules-runtime.js:197:9)
W20170329-10:07:49.305(7)? (STDERR) at Module.require (packages/modules-runtime.js:120:16)
W20170329-10:07:49.305(7)? (STDERR) at Module.Mp.importSync (/Users/theara/.meteor/packages/modules/.0.9.0-beta.13.ag5gz5++os+web.browser+web.cordova/npm/node_modules/reify/lib/runtime.js:88:16)
W20170329-10:07:49.306(7)? (STDERR) at meteorInstall.imports.api.posts.methods.js (imports/api/posts/methods.js:1:1)
W20170329-10:07:49.306(7)? (STDERR) at fileEvaluate (packages/modules-runtime.js:197:9)
And then I tried to remove Posts.attachSchema(Posts.schema);, It work fine.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 1
- Comments: 27
Right now it’s possible to use another approach as described here:
{ friends: { type: Array }, 'friends.$': { type: String }, }Actually, there mentioned that we can use{ friends: [String], }but it doesn’t work.My problem turned out to be that, for some reason, when I added an unspecified version of collection2-core, I wound up with an older version. Per the advice of somebody in a different thread, I uninstalled all the old aldeed stuff, then did this:
meteor add aldeed:collection2-core@2.0.1This fixed my problem.
Hi all, here are some pointers:
aldeed:simple-schema,aldeed:collection2,aldeed:autoformfirst. If you still see any variations of these packages in the.meteor/versionsfile after this, then keep removing other packages that depend these packages until they disappear from the versions file.meteor add aldeed:collection2-core. Version 2 or greater will work. Make SURE you have the-coreon there! You do not wantaldeed:collection2package, which will pull in the oldaldeed:simple-schemadependency again.