added timestamps to example Schema

This commit is contained in:
Ben Elferink
2020-12-29 17:53:47 +02:00
committed by GitHub
parent f862566c54
commit 833ac944c3

View File

@@ -1,13 +1,18 @@
import mongoose from 'mongoose'; import mongoose from 'mongoose';
const instance = new mongoose.Schema({ const instance = new mongoose.Schema(
_id: mongoose.Schema.Types.ObjectId, // _id is set by default, (you can remove this line) {
/* _id: mongoose.Schema.Types.ObjectId, // _id is set by default, (you can remove this line)
/*
name = property of document object name = property of document object
String = type of value ---> https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures String = type of value ---> https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures
*/ */
name: String, name: String,
}); },
{
timestamps: true,
},
);
// document = model name ---> https://mongoosejs.com/docs/guide.html // document = model name ---> https://mongoosejs.com/docs/guide.html
// note: use a singular name, mongoose automatically creates a collection like so -> model: 'Person' === collection: 'people' // note: use a singular name, mongoose automatically creates a collection like so -> model: 'Person' === collection: 'people'