const mongoose = require('mongoose')
const schema = new mongoose.Schema({
title: {
type: String,
required: true,
unique: true,
minlength: 2
},
published: {
type: Number,
},
author: {
type: mongoose.Schema.Types.ObjectId,
ref: 'Author'
},
genres: [
{ type: String}
]
})
module.exports = mongoose.model('Book', schema)
const mongoose = require('mongoose')
const schema = new mongoose.Schema({
name: {
type: String,
required: true,
unique: true,
minlength: 4
},
born: {
type: Number,
},
})
module.exports = mongoose.model('Author', schema)