File tree Expand file tree Collapse file tree 1 file changed +18
-7
lines changed Expand file tree Collapse file tree 1 file changed +18
-7
lines changed Original file line number Diff line number Diff line change @@ -18,15 +18,26 @@ client.connect().then(() => {
18
18
19
19
let counter = 0 ;
20
20
sets . find ( { } ) . forEach ( async set => {
21
- counter ++ ;
22
21
if ( counter % 10 === 0 ) {
23
- console . log ( set . name ) ;
24
- }
25
- for ( let i = 0 ; i < set . packets . length ; i ++ ) {
26
- set . packets [ i ] = await packets . findOne ( { _id : set . packets [ i ] } ) ;
22
+ console . log ( counter , set . name ) ;
27
23
}
28
24
29
- sets . updateOne ( { _id : set . _id } , { $set : { packets : set . packets } } ) ;
30
- } )
25
+ counter ++ ;
26
+
27
+ sets . updateOne ( { _id : set . _id } , {
28
+ $push : {
29
+ packets : {
30
+ $each : [ ] ,
31
+ $sort : {
32
+ name : 1
33
+ }
34
+ }
35
+ }
36
+ } ) ;
37
+
38
+ set . packets . forEach ( packet => {
39
+ questions . updateMany ( { packet : packet . _id } , { $set : { packetNumber : packet . name } } ) ;
40
+ } )
41
+ } ) ;
31
42
console . log ( 'success' ) ;
32
43
} ) ;
You can’t perform that action at this time.
0 commit comments