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

Some checking errors #40

Closed
matteodem opened this issue Jan 8, 2014 · 2 comments
Closed

Some checking errors #40

matteodem opened this issue Jan 8, 2014 · 2 comments

Comments

@matteodem
Copy link

I noticed that if you have this as the collection 2 definition:

collection = new Meteor.Collection2("ognoCart", {
    'schema' : {
        'product' : {
            'type' : String,
            'label' : "Product _id reference"
        },
        'owner' : {
            'type' : String,
            'label' : "Owner _id reference"
        }
    }
});

Then you get a true in a lot of (to me) weird cases:

collection.insert({ 'product' : 'someId', 'owner'  : 'someId', 'alsoThis' : 'shouldnt work' }); // works
collection.insert({ 'product' : false, 'owner'  : true }); // works
collection.insert({ 'product' : 123, 'owner'  : 321 }); // works
@aldeed
Copy link
Collaborator

aldeed commented Jan 8, 2014

These all work because of the automatic cleaning that collection2 does. It's true that the insert command is successful, but if you look in mongo, or do a findOne to check out what was saved, nothing invalid is saved. In the first case, alsoThis is stripped out. In the other cases, the values are saved, but only after being converted to strings.

Usually I think this would be the desired behavior, to avoid unnecessary errors being displayed to users, but we could add an option to disable the automatic cleaning if you think it's useful.

@matteodem
Copy link
Author

Oh, yeah after further investigating into it and also having a look how it reacts with Booleans, other Javascript Types I think it's quite nice to have that.

I'll close this issue then, thanks for explaining.

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

2 participants