-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#15] feat - Add MediaRelation schema
Co-authored-by: Leonardo Barreiros <leossb36@gmail.com>
- Loading branch information
1 parent
fefa126
commit e1faa51
Showing
4 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | ||
import { Document } from 'mongoose'; | ||
|
||
export type MediaRelationDocument = MediaRelation & Document; | ||
|
||
@Schema() | ||
export class MediaRelation { | ||
@Prop() | ||
mediaId: string; | ||
|
||
@Prop() | ||
locationID: string; | ||
} | ||
|
||
export const MediaRelationSchema = SchemaFactory.createForClass(MediaRelation); | ||
|
||
MediaRelationSchema.virtual('id').get(function () { | ||
return this._id.toHexString(); | ||
}); | ||
|
||
MediaRelationSchema.virtual('dateAdded').get(function () { | ||
return this._id.getTimestamp(); | ||
}); | ||
|
||
MediaRelationSchema.set('toJSON', { | ||
virtuals: true, | ||
transform: function (doc, ret) { | ||
delete ret._id; | ||
delete ret.__v; | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters