Mongoose/MongoDB: Index Array of Embedded Documents
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import timestamp from 'mongoose-timestamp'; | |
export default function(mongoose) { | |
let | |
Schema = mongoose.Schema; | |
/** | |
* @type {Schema} | |
*/ | |
let RequireSchema = new Schema({ | |
/** | |
* The unit required. | |
* @type {ObjectId} | |
*/ | |
unit: { type: Schema.Types.ObjectId, ref: 'Unit' }, | |
/** | |
* The channels required for the specified unit. | |
* @type {Array} | |
*/ | |
channels: [{ | |
tag: { type: String }, | |
name: { type: String }, | |
number: { type: Number } | |
}], | |
/** | |
* The channels required for the specified unit. | |
* @type {Array} | |
*/ | |
measurements: [{ | |
tag: { type: String }, | |
name: { type: String }, | |
id: { type: Schema.Types.ObjectId, ref: 'UnitMeasurement' } | |
}] | |
}); | |
DependentSchema.plugin(timestamp); | |
return DependentSchema; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment