mongoose-type-url
v2.1.0
Published
A url field-type for Mongoose schemas
Downloads
5,944
Readme
mongoose-type-url
A url field-type for Mongoose schemas
usage
This will validate a url, correctly:
var mongoose = require('mongoose');
require('mongoose-type-url');
var UserSchema = new mongoose.Schema({
url: {
work: mongoose.SchemaTypes.Url,
profile: mongoose.SchemaTypes.Url
}
});
You can also use the stuff in String
type:
var UserSchema = new mongoose.Schema({
url: {
work: {type: mongoose.SchemaTypes.Url, required: true},
profile: {type: mongoose.SchemaTypes.Url, required: true},
}
});
You can also use it as an array:
var UserSchema = new mongoose.Schema({
urls: [{type: mongoose.SchemaTypes.Url}]
});