File tree Expand file tree Collapse file tree 1 file changed +12
-9
lines changed
apps/backend/src/research/entries Expand file tree Collapse file tree 1 file changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -13,15 +13,18 @@ export class EntriesService {
13
13
private readonly em : EntityManager
14
14
) { }
15
15
16
- create ( { weekday, ...rest } : EntryCreationDto ) {
17
- return this . entryRepository . insertMany (
18
- weekday . map ( ( w ) => {
19
- const entry = new Entry ( ) ;
20
- entry . assign ( { weekday : w , ...rest } , { em : this . em } ) ;
21
-
22
- return entry ;
23
- } )
24
- ) ;
16
+ async create ( { weekday, ...rest } : EntryCreationDto ) {
17
+ const entries = weekday . map ( ( w ) => {
18
+ const entry = new Entry ( ) ;
19
+ entry . assign ( { ...rest , weekday : w } , { em : this . em } ) ;
20
+
21
+ this . em . persist ( entry ) ;
22
+ return entry ;
23
+ } ) ;
24
+
25
+ await this . em . flush ( ) ;
26
+
27
+ return entries . map ( ( entries ) => entries . toObject ( ) . id ) ;
25
28
}
26
29
27
30
async findAll ( ) {
You can’t perform that action at this time.
0 commit comments