Skip to content
This repository has been archived by the owner on Jun 29, 2021. It is now read-only.

Commit

Permalink
Updated 'ref' parameter to allow population by string (#154)
Browse files Browse the repository at this point in the history
Updated 'ref' parameter to allow population by string
  • Loading branch information
ChristianPraiss authored and Ben305 committed Aug 20, 2018
1 parent 7d5a021 commit 252c740
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/prop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,20 @@ const baseProp = (rawOptions, Type, target, key, isArray = false) => {
}

const ref = rawOptions.ref;
if (ref) {
if (typeof ref === 'string') {
schema[name][key] = {
...schema[name][key],
type: mongoose.Schema.Types.ObjectId,
ref: ref.name,
ref,
};
return;
} else if (ref) {
schema[name][key] = {
...schema[name][key],
type: mongoose.Schema.Types.ObjectId,
ref: ref.name,
};
return;
}

const itemsRef = rawOptions.itemsRef;
Expand Down

0 comments on commit 252c740

Please sign in to comment.