-
Notifications
You must be signed in to change notification settings - Fork 42
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
Mongoose Schema fields options #102
Comments
Obviously, you can't "directly" you var UserSchema = new js.npm.mongoose.Schema({
username: {
type: "String", // strings are usually safer here
unique: true,
required: true
},
password: {
type: "String",
required: true
}
});
var userModel = js.npm.Mongoose.mongoose.model('User', userSchema); This is the "untyped", extern-only way of doing it: you won't have type safety when using this model (documents won't be typed automatically as There is an alternative way of declaring schemas, using typedef UserData = {
@:unique @:required var username : String;
@:unique @:required var password : String;
}; see https://github.com/clemos/haxe-js-kit/blob/develop/util/Mongoose.hx#L435-L485 Let me know if the example is clear enough for you to adapt it to your needs, and if it's what you would expect. |
I missed those metadata. Thank you very much, your answer is very clear, it is what I was expecting... |
Hi !
Is this kind of Schema declarations supported ?
If yes, how can we do this ?
If not how could we add this ? :)
Thanks !
The text was updated successfully, but these errors were encountered: