Skip to content

Commit

Permalink
docs: add note about using ref as function
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Aug 21, 2020
1 parent 19a7eb4 commit 1256d77
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/schematype.js
Expand Up @@ -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({
Expand Down

0 comments on commit 1256d77

Please sign in to comment.