mongoose-type-url

A url field-type for Mongoose schemas

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 Stringtype:

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}]
});

HomePage

https://github.com/konsumer/mongoose-type-url

Repository

https://github.com/konsumer/mongoose-type-url.git


上一篇:AJAX原理及常见面试题
下一篇:idylle

相关推荐

官方社区

扫码加入 JavaScript 社区