O'Reilly logo
  • Patrick S thinks this is interesting:

So, by breaking this down, in our projectSchema we want to set the createdBy path to be:

  • An object {}
  • To contain the name of the model to be used—ref: 'User'
  • and the SchemaType of the linked schema object—type: mongoose.Schema.Types.ObjectId

So, by putting this back together, we can change the createdBy declaration in our projectSchema like this:


Cover of Mongoose for Application Development


population example