Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple-Schema: TypeError: Object [object Object] has no method 'attachSchema' #147

Closed
CaptainChainsaw opened this issue Sep 7, 2014 · 9 comments

Comments

@CaptainChainsaw
Copy link

Hi,

I'm running Meteor 0.9.1.1 and I keep getting issues with simple-schema:

$ meteor
[[[[[ ~/game ]]]]]

=> Started proxy.
=> Started MongoDB.     
W20140907-08:06:03.233(-7)? (STDERR) 
W20140907-08:06:03.357(-7)? (STDERR) /home/me/.meteor/packages/meteor-tool/.1.0.28.tx8gz++os.linux.x86_64+web.browser+web.cordova/meteor-tool-os.linux.x86_64/dev_bundle/lib/node_modules/fibers/future.js:173
W20140907-08:06:03.358(-7)? (STDERR)                        throw(ex);
W20140907-08:06:03.362(-7)? (STDERR)                              ^
W20140907-08:06:03.363(-7)? (STDERR) TypeError: Object [object Object] has no method 'attachSchema'
W20140907-08:06:03.364(-7)? (STDERR)     at app/lib/schema-Account-Type.js:22:13
W20140907-08:06:03.365(-7)? (STDERR)     at app/lib/schema-Account-Type.js:25:3
W20140907-08:06:03.365(-7)? (STDERR)     at /home/me/game/.meteor/local/build/programs/server/boot.js:161:10
W20140907-08:06:03.365(-7)? (STDERR)     at Array.forEach (native)
W20140907-08:06:03.366(-7)? (STDERR)     at Function._.each._.forEach (/home/me/.meteor/packages/meteor-tool/.1.0.28.tx8gz++os.linux.x86_64+web.browser+web.cordova/meteor-tool-os.linux.x86_64/dev_bundle/lib/node_modules/underscore/underscore.js:79:11)
W20140907-08:06:03.366(-7)? (STDERR)     at /home/me/game/.meteor/local/build/programs/server/boot.js:82:5
=> Exited with code: 8

This is the file that contains my schema:

AccountType = new Meteor.Collection("AccountType");
Schema = {};
Schema.AccountType = new SimpleSchema({
    accountType: {
        type: String,
        allowedValues: ['test', 'live']
    },
    createdBy: {
        type: String,
        autoValue: function(){ return this.userId }
    }
});

SimpleSchema.debug = true;
AccountType.attachSchema(Schema.AccountType);

This schema was previously working on an earlier version of Meteor.

Any ideas what the issue with this could be?

@aldeed
Copy link
Collaborator

aldeed commented Sep 7, 2014

Probably because I haven't updated collection2 for the backwards-incompatible changes in 0.9.1 yet. Hopefully I can have a new release out later today.

@CaptainChainsaw
Copy link
Author

Ahhh ok, no problem and thank you :) ..... Using Meteor 0.9.0.1 I did get this error :

"Error: unknown package: simple-schema"

I was trying to install CollectionFS and cfs:filesystem (they did seem to install ok). Would this be related?

Further info here:
http://stackoverflow.com/questions/25701770/meteor-0-9-0-1-simple-schema-not-found-after-installing-collectionfs-and-cfsfi

@aldeed
Copy link
Collaborator

aldeed commented Sep 7, 2014

In the new package system, it should be aldeed:simple-schema, so meteor remove simple-schema followed by meteor add aldeed:simple-schema should work.

Also, CFS is released on the new packaging system now, so I wouldn't recommend trying to install with meteorite anymore. https://github.com/CollectionFS/Meteor-CollectionFS/blob/devel/README.md#converting-from-pre-090-meteor

@CaptainChainsaw
Copy link
Author

I'll give that a go thank you very much :)

@CaptainChainsaw
Copy link
Author

All fixed now :) ... ended up having to create a new meteor app though.

@aj07mm
Copy link
Contributor

aj07mm commented Jan 12, 2015

i had the same prob, fixed by removing houston, one of my packages. Seems that some packages are stubbing simple schema and ending up ocourring this type of error.

@laughingturtle
Copy link

What do you mean by 'stubbing' ?

@mvgalle
Copy link

mvgalle commented Jun 6, 2016

In your terminal try adding the following package to your application :

meteor add aldeed:collection2

Solved the problem for me. :)

@oruchepaschal
Copy link

Had same issues with meteor app: "ReferenceError: SimpleSchema is not defined"
open terminal in the project folder and type the following command meteor add aldeed:collection2
result:
**Changes to your project's package version selections:

aldeed:collection2 added, version 2.7.1
aldeed:simple-schema added, version 1.5.3
mdg:validation-error added, version 0.2.0**

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants