Created
August 20, 2015 23:30
-
-
Save mokolodi1/7538a76782350c15e393 to your computer and use it in GitHub Desktop.
SimpleSchema cheat sheet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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