@@ -138,7 +138,6 @@ function reIndex (db, fromIndexName, toIndexName, next) {
138138 } ) . then ( res => {
139139 next ( )
140140 } ) . catch ( err => {
141- console . error ( err )
142141 next ( err )
143142 } )
144143}
@@ -215,58 +214,40 @@ function putMappings (db, indexName, next) {
215214 let pageSchema = loadSchema ( 'cms_page' , '5.6' ) ;
216215 let blockSchema = loadSchema ( 'cms_block' , '5.6' ) ;
217216
218- db . indices . putMapping ( {
219- index : indexName ,
220- type : 'product' ,
221- body : productSchema
222- } ) . then ( res1 => {
223- console . dir ( res1 , { depth : null , colors : true } )
224-
217+ Promise . all ( [
218+ db . indices . putMapping ( {
219+ index : indexName ,
220+ type : 'product' ,
221+ body : productSchema
222+ } ) ,
225223 db . indices . putMapping ( {
226224 index : indexName ,
227225 type : 'taxrule' ,
228226 body : taxruleSchema
229- } ) . then ( res2 => {
230- console . dir ( res2 , { depth : null , colors : true } )
231-
232- db . indices . putMapping ( {
233- index : indexName ,
234- type : 'attribute' ,
235- body : attributeSchema
236- } ) . then ( res3 => {
237- console . dir ( res3 , { depth : null , colors : true } )
238- db . indices . putMapping ( {
239- index : indexName ,
240- type : 'cms_page' ,
241- body : pageSchema
242- } ) . then ( res4 => {
243- console . dir ( res4 , { depth : null , colors : true } )
244- db . indices . putMapping ( {
245- index : indexName ,
246- type : 'cms_block' ,
247- body : blockSchema
248- } ) . then ( res5 => {
249- console . dir ( res5 , { depth : null , colors : true } )
250- db . indices . putMapping ( {
251- index : indexName ,
252- type : 'category' ,
253- body : categorySchema
254- } ) . then ( res6 => {
255- console . dir ( res6 , { depth : null , colors : true } )
256- next ( )
257- } )
258- } )
259- } )
260- } ) . catch ( err3 => {
261- throw new Error ( err3 )
262- } )
263- } ) . catch ( err2 => {
264- throw new Error ( err2 )
227+ } ) ,
228+ db . indices . putMapping ( {
229+ index : indexName ,
230+ type : 'attribute' ,
231+ body : attributeSchema
232+ } ) ,
233+ db . indices . putMapping ( {
234+ index : indexName ,
235+ type : 'cms_page' ,
236+ body : pageSchema
237+ } ) ,
238+ db . indices . putMapping ( {
239+ index : indexName ,
240+ type : 'cms_block' ,
241+ body : blockSchema
242+ } ) ,
243+ db . indices . putMapping ( {
244+ index : indexName ,
245+ type : 'category' ,
246+ body : categorySchema
265247 } )
266- } ) . catch ( err1 => {
267- console . error ( err1 )
268- next ( err1 )
269- } )
248+ ] ) . then ( values => values . forEach ( res => console . dir ( res . body , { depth : null , colors : true } ) ) )
249+ . then ( next )
250+ . catch ( next )
270251}
271252
272253module . exports = {
0 commit comments