Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/deepsyx/mongoose-minid
(NodeJS) ShortId for mongoose ODM.
https://github.com/deepsyx/mongoose-minid
javascript mongodb mongoose nodejs objectid shortid
Last synced: 3 days ago
JSON representation
(NodeJS) ShortId for mongoose ODM.
- Host: GitHub
- URL: https://github.com/deepsyx/mongoose-minid
- Owner: deepsyx
- Created: 2014-01-20T20:42:52.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2016-08-30T21:31:57.000Z (about 8 years ago)
- Last Synced: 2024-08-09T06:55:17.500Z (3 months ago)
- Topics: javascript, mongodb, mongoose, nodejs, objectid, shortid
- Language: JavaScript
- Homepage:
- Size: 5.86 KB
- Stars: 3
- Watchers: 3
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
THIS PACKAGE IS NO LONGER SUPPORTED AND WILL NOT BE UPDATED. I HIGHLY DISCOURAGE USING IT.
================mongoose-minid
================This plugin is a highly customised version of mongoose-shortid, without bignum.
You can get it via npm by typing:
```npm
npm install mongoose-minid
```This plugin provides a new Schema Type, ShortId, that can be used in place of ObjectId. The generated IDs are random url-safe strings of configurable length, represented in a 64 bit string.
This plugin will automatically retry inserts on a collision, up to a maximum of 5 retries.
### What's the point?
This module is going to make your ObjectId from something like `507f191e810c19729de860ea` to just `Ng3zf_`
### Usage
```javascript
var mongoose = require('mongoose');
var ShortId = require('mongoose-minid');var personSchema = mongoose.Schema({
_id: ShortId,
name: String
});
```### Options
The default options are:
```javascript
var personSchema = mongoose.Schema({
_id: {
type: ShortId,
len: 7 // Length 7 characters
},
name: String
});
```