refactored template
This commit is contained in:
27
server/api/models/User.js
Normal file
27
server/api/models/User.js
Normal file
@@ -0,0 +1,27 @@
|
||||
import mongoose from 'mongoose';
|
||||
|
||||
const instance = new mongoose.Schema(
|
||||
{
|
||||
_id: mongoose.Schema.Types.ObjectId, // _id is set by default, (you can remove this line)
|
||||
|
||||
/*
|
||||
name = Object key
|
||||
String = Type
|
||||
*/
|
||||
name: String,
|
||||
},
|
||||
{
|
||||
timestamps: true,
|
||||
// this creates and maintains:
|
||||
// {
|
||||
// createdAt: Date,
|
||||
// updatedAt: Date,
|
||||
// }
|
||||
},
|
||||
);
|
||||
|
||||
// NOTE! use a singular model name, mongoose automatically creates a collection like so:
|
||||
// model: 'User' === collection: 'users'
|
||||
const modelName = 'User';
|
||||
|
||||
export default mongoose.model(modelName, instance);
|
||||
Reference in New Issue
Block a user