@cylution/mongoose-plugin-timestamps-immutable
Simple mongoose plugin that prevents update createdAt
Getting started
Install
npm i @cylution/mongoose-plugin-timestamps-immutable
or
yarn add @cylution/mongoose-plugin-timestamps-immutable
Usage
You need set schema options
timestamps: true
to tell plugin modify schema
const demoSchema = new Schema({
name: String
}, {
timestamps: true // <~~ set it
})
Typescript
import { pluginTimestampsImmutable } from '@cylution/mongoose-plugin-timestamps-immutable'
import { plugin, Schema } from 'mongoose'
Javascript
const { pluginTimestampsImmutable } = require('@cylution/mongoose-plugin-timestamps-immutable')
const { plugin } = require('mongoose')
// global
plugin(pluginTimestampsImmutable)
// or schema
const userSchema = new Schema({
//
}, {
timestamps: true,
})
userSchema.plugin(pluginTimestampsImmutable)
License
This project is licensed under the MIT License.