Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
413 views
in Technique[技术] by (71.8m points)

javascript - What is need of specifying ref here in the below mongoose schema? What if we don't specify it?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Ref is an option of mongoose to populate a field given a schema. So in case you omit ref in your "eventsAttended" field, you get only an objectID value, with no reference to any schema.

Docs here: https://mongoosejs.com/docs/api.html#schematype_SchemaType-ref

Guide here: https://mongoosejs.com/docs/populate.html


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...