Skip to content

Instantly share code, notes, and snippets.

@mokolodi1
Created August 20, 2015 23:30
Show Gist options
  • Save mokolodi1/7538a76782350c15e393 to your computer and use it in GitHub Desktop.
Save mokolodi1/7538a76782350c15e393 to your computer and use it in GitHub Desktop.
SimpleSchema cheat sheet
var schemaName = new SimpleSchema({
"first_field": {
type: String|Number|Boolean|[Object],
label: "First field",
optional: true,
custom: function () {
if (Meteor.isClient && this.isSet) {
Meteor.call("accountsIsUsernameAvailable", this.value, function (error, result) {
if (!result) {
Meteor.users.simpleSchema().namedContext("createUserForm").addInvalidKeys([{name: "username", type: "notUnique"}]);
}
});
}
}
},
});
MyCollection = new Meteor.Collection("my-collection");
MyCollection.attachSchema(schemaName);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment