File tree Expand file tree Collapse file tree 3 files changed +28
-1
lines changed
Expand file tree Collapse file tree 3 files changed +28
-1
lines changed Original file line number Diff line number Diff line change 11export * from './database/Seeder'
22export * from './database/Factory'
33
4+ export * from './resources/Resource'
5+
46export * from './decorators/Ignore'
57export * from './decorators/Options'
68export * from './decorators/ExtraParams'
Original file line number Diff line number Diff line change 11{
22 "name" : " @secjs/base" ,
3- "version" : " 1.2.5 " ,
3+ "version" : " 1.2.6 " ,
44 "license" : " MIT" ,
55 "author" : " João Lenon" ,
66 "repository" : " https://github.com/SecJS/Base.git" ,
Original file line number Diff line number Diff line change 1+ export function Resource < JsonResource > ( ) {
2+ return class Resource {
3+ static blueprint ( model : any ) {
4+ return model
5+ }
6+
7+ static toJson ( model : any ) : JsonResource {
8+ if ( ! model ) return null
9+
10+ const blueprint = this . blueprint ( model )
11+
12+ Object . keys ( blueprint ) . forEach ( key => {
13+ if ( ! blueprint [ key ] ) delete blueprint [ key ]
14+ } )
15+
16+ return JSON . parse ( JSON . stringify ( blueprint ) )
17+ }
18+
19+ static toArray ( models : any [ ] ) : JsonResource [ ] {
20+ if ( ! models ) return null
21+
22+ return models . map ( model => this . toJson ( model ) )
23+ }
24+ }
25+ }
You can’t perform that action at this time.
0 commit comments