This repository has been archived by the owner on Jun 29, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add @mapProp for Maps with tests (#342)
- add @mapProp - add tests for @mapProp - add @mapProp README docs - polish & rebase of #284
- Loading branch information
Showing
4 changed files
with
152 additions
and
36 deletions.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { mapProp, prop, Typegoose } from '../../src/typegoose'; | ||
|
||
export class SideNote { | ||
@prop() | ||
public content: string; | ||
|
||
@prop() | ||
public link?: string; | ||
} | ||
|
||
enum ProjectValue { | ||
WORKING = 'working', | ||
UNDERDEVELOPMENT = 'underdevelopment', | ||
BROKEN = 'broken', | ||
} | ||
|
||
class InternetUser extends Typegoose { | ||
@mapProp({ of: String, mapDefault: {} }) | ||
public socialNetworks?: Map<string, string>; | ||
|
||
@mapProp({ of: SideNote }) | ||
public sideNotes?: Map<string, SideNote>; | ||
|
||
@mapProp({ of: String, enum: ProjectValue }) | ||
public projects: Map<string, ProjectValue>; | ||
} | ||
|
||
export const model = new InternetUser().getModelForClass(InternetUser); |