Which of the following code is better wrt performance?

Posts = new Mongo.Collection("posts");

Posts.attachSchema(new SimpleSchema({
  title: {
    type: String
  }
}));

or

Posts = new Mongo.Collection("posts"); 
var Schemas = {};
Schemas.Post = new SimpleSchema({
  title: {
    type: String
  }
});  
Posts.attachSchema(Schemas.Post);

If you’re asking which one has better write performance, it doesn’t matter. As for general performance, it wouldn’t matter either.

Also the last line of the second snippet should be:

Posts.attachSchema(Schemas.Post);

Those are basically exactly the same, I think.

1 Like