Spaces:
Sleeping
Sleeping
| const mongoose = require('mongoose'); | |
| const colourSchema = new mongoose.Schema( | |
| { | |
| name: { type: String, required: true }, | |
| code: { type: String, required: true }, | |
| hex: { type: String, required: true }, | |
| lrv: { type: Number }, | |
| family: { type: String, required: true }, | |
| colorCollection: { type: mongoose.Schema.Types.ObjectId, ref: 'ColourCollection' }, | |
| finishes: [{ type: String }], | |
| linkedProducts: [{ type: mongoose.Schema.Types.ObjectId, ref: 'Product' }], | |
| isActive: { type: Boolean, default: true }, | |
| }, | |
| { timestamps: true } | |
| ); | |
| colourSchema.index({ family: 1, isActive: 1 }); | |
| colourSchema.index({ collection: 1 }); | |
| colourSchema.index({ name: 'text', code: 'text' }); | |
| module.exports = mongoose.model('Colour', colourSchema); | |