https://github.com/tilap/mongoose-plugin-updatedat
Mongoose plugin to add a updated_at property to schema
https://github.com/tilap/mongoose-plugin-updatedat
Last synced: over 1 year ago
JSON representation
Mongoose plugin to add a updated_at property to schema
- Host: GitHub
- URL: https://github.com/tilap/mongoose-plugin-updatedat
- Owner: tilap
- License: mit
- Created: 2016-04-25T12:06:52.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-04-25T12:07:51.000Z (about 10 years ago)
- Last Synced: 2025-03-07T03:47:45.876Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Mongoose plugin updatedat [![NPM version][npm-image]][npm-url]
============================
Simple mongoose plugin to add a updated_at property to your schema, that automatically update with timestamp on change.
## Install
```
npm install --save mongoose-plugin-updatedat
```
## Usage
```
const Schema = require('mongoose').Schema;
const mongoosePluginUpdatedAt = require('mongoose-plugin-updatedat');
let MySchema = new Schema({ ... });
MySchema.plugin(mongoosePluginUpdatedAt);
```
## Options
Available options:
- ```index```: if you want to index the property
- ```name```: the name of the field - default is updated_at
### Example
```
const Schema = require('mongoose').Schema;
const mongoosePluginUpdatedAt = require('mongoose-plugin-updatedat');
let MySchema = new Schema({ ... });
MySchema.plugin(mongoosePluginUpdatedAt, {
index: true,
name: 'updated_at_custome_name',
});
```
## License
MIT
[npm-image]: https://img.shields.io/npm/v/mongoose-plugin-updatedat.svg?style=flat
[npm-url]: https://npmjs.org/package/mongoose-plugin-updatedat