https://github.com/konsumer/mongoose-type-url
A url field-type for Mongoose schemas
https://github.com/konsumer/mongoose-type-url
Last synced: over 1 year ago
JSON representation
A url field-type for Mongoose schemas
- Host: GitHub
- URL: https://github.com/konsumer/mongoose-type-url
- Owner: konsumer
- Created: 2015-01-27T12:13:43.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2020-10-05T19:50:53.000Z (over 5 years ago)
- Last Synced: 2025-03-17T02:51:24.777Z (over 1 year ago)
- Language: JavaScript
- Size: 1.91 MB
- Stars: 15
- Watchers: 3
- Forks: 7
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# mongoose-type-url
A url field-type for Mongoose schemas
[](https://www.npmjs.com/package/mongoose-type-url)
[](https://greenkeeper.io/)
[](https://travis-ci.org/konsumer/mongoose-type-url)
[](https://codeclimate.com/github/konsumer/mongoose-type-url)
## usage
This will validate a url, correctly:
```js
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:
```js
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:
```js
var UserSchema = new mongoose.Schema({
urls: [{type: mongoose.SchemaTypes.Url}]
});
```