Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/saintedlama/mongoose-valid-id
Adds a `isValidId` static method to the model that can be used to check if a passed id is a valid mongoose/mongodb id
https://github.com/saintedlama/mongoose-valid-id
Last synced: about 2 months ago
JSON representation
Adds a `isValidId` static method to the model that can be used to check if a passed id is a valid mongoose/mongodb id
- Host: GitHub
- URL: https://github.com/saintedlama/mongoose-valid-id
- Owner: saintedlama
- Created: 2015-01-19T12:30:01.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-01-19T12:33:41.000Z (almost 10 years ago)
- Last Synced: 2024-10-12T12:25:44.638Z (3 months ago)
- Language: JavaScript
- Size: 117 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Mongoose valid id is a mongoose plugin that adds a `isValidId` static method to the model that can be used to check
if a passed id is a valid mongoose/mongodb id.## Installation
$ npm install mongoose-valid-id
## Usage
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var validId = require('mongoose-valid-id');var Page = new Schema({
title : { type : String, required : true},
content : { type : String, required : true },
path : { type : String, required : true},
tags : [String],lastModified : Date,
created : Date
});Page.plugin(mongoose-valid-id);
Use the `isValidId` static methodvar Page = require('page');
Page.isValidId('someid'); // Returns false
Page.isValidId('543be48d3b1b8a601ca20990'); // Returns true