Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

mongoos populate a ref

const storySchema = Schema({
  authors: [{ type: Schema.Types.ObjectId, ref: 'Person' }],
  title: String
});

// Later

const story = await Story.findOne({ title: 'Casino Royale' }).populate('authors');
story.authors; // `[]`
Source by mongoosejs.com #
 
PREVIOUS NEXT
Tagged: #mongoos #populate #ref
ADD COMMENT
Topic
Name
7+7 =