James Mcgill
Programmer
I understand how to build a schema, but I not sure how to build one for a project I am working on now. I need to build a schema for haikus, I am not sure the best way to build it but I came up with this design, what is throwing me off is the fact that the 5-7-5-syllables. How do i account for the syllables?
JavaScript:
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const PoemsSchema = new Schema({
user: {
type: Schema.Types.ObjectId,
ref: 'users'
},
title: {
type: String,
require: true
},
poem: [
{
lineOne: {
type: String,
require: true
},
lineTwo: {
type: String,
require: true
},
lineThree: {
type: String,
require: true
}
}
],
likes: [
{
user: {
type: Schema.Types.ObjectId,
ref: 'users'
}
}
]
});
module.exports = mongoose.model('poems', PoemsSchema);