I am trying to design my database model and i dont have clue how to fit array of strings and array of objects into it. My current model is:
const mongoose = require("mongoose");
const Schema = mongoose.Schema;
const schema = new Schema({
email: { type: String, unique: true, required: true },
hash: { type: String, required: true },
createdDate: { type: Date, default: Date.now },
settings: {
favorites: { /* ??? */ },
cart: { /* ??? */ },
states: {
favorites: { type: Boolean, default: true },
search: { type: Boolean, default: false },
category: { type: Schema.Types.Mixed, default: false }
}
}
});
schema.set("toJSON", { virtuals: true });
module.exports = mongoose.model("User", schema);
favorites data structure is ['234', '564', '213', '782']
cart example data structure is:
[
{ quantity: 5, marketId: '234' },
{ quantity: 2, marketId: '564' },
{ quantity: 7, marketId: '213' },
{ quantity: 3, marketId: '782' }
]
How can i add this as configuration to the mongoose model?