mongoose-type-url

2019-12-03 admin

mongoose-type-url是什么

什么是mongoose-type-url,A url field-type for Mongoose schemas

mongoose-type-url使用教程帮助文档

mongoose-type-url

A url field-type for Mongoose schemas

npm

Greenkeeper badge Build Status Code Climate

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

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-80311.html

文章标题:mongoose-type-url

回到顶部