Skip to content

Instantly share code, notes, and snippets.

@jgornick
Created May 9, 2015 17:46
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save jgornick/21f10fde65ba00ef7b2f to your computer and use it in GitHub Desktop.
Mongoose/MongoDB: Index Array of Embedded Documents
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