express-api-example/app/models/note.js

18 lines
357 B
JavaScript

const mongoose = require('mongoose');
const { Schema } = mongoose;
const NoteSchema = new Schema({
title: {
type: String, required: [true, "can't be blank"],
},
text: {
type: String, required: [true, "can't be blank"],
},
user: {
type: Schema.Types.ObjectId, ref: 'User',
},
}, { timestamps: true });
module.exports = NoteSchema;