Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/Savy011/fullstackopen-exercises. My Exercise Submissions for FullStack Open fullstackopen.com/en
Something went wrong. Try again.
520 B · 25 lines
JavaScript
at main
12345678910111213141516171819202122232425const mongoose = require('mongoose')const uniqueValidator = require('mongoose-unique-validator')
const bookSchema = new mongoose.Schema({ title: { type: String, required: true, unique: true, minLenght: 5 }, published: { type: Number, }, author: { type: mongoose.Schema.Types.ObjectId, ref: 'Author' }, genres: [ { type: String } ]})
bookSchema.plugin(uniqueValidator)
module.exports = mongoose.model('Book', bookSchema)