From 1256d77da5a147679f80ddd2c01ac7b44068ecae Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Fri, 21 Aug 2020 14:17:24 -0400 Subject: [PATCH] docs: add note about using `ref` as function --- lib/schematype.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/schematype.js b/lib/schematype.js index 938a376c48b..82dd98ef568 100644 --- a/lib/schematype.js +++ b/lib/schematype.js @@ -960,8 +960,10 @@ SchemaType.prototype.required = function(required, message) { * const User = mongoose.model('User', userSchema); * * const postSchema = new Schema({ user: mongoose.ObjectId }); - * postSchema.path('user').ref('User'); // By model name - * postSchema.path('user').ref(User); // Can pass the model as well + * postSchema.path('user').ref('User'); // Can set ref to a model name + * postSchema.path('user').ref(User); // Or a model class + * postSchema.path('user').ref(() => 'User'); // Or a function that returns the model name + * postSchema.path('user').ref(() => User); // Or a function that returns the model class * * // Or you can just declare the `ref` inline in your schema * const postSchema2 = new Schema({