Skip to content

Instantly share code, notes, and snippets.

@victorkurauchi
Last active August 29, 2015 14:03
Show Gist options
  • Select an option

  • Save victorkurauchi/ad440bb38908cc01f964 to your computer and use it in GitHub Desktop.

Select an option

Save victorkurauchi/ad440bb38908cc01f964 to your computer and use it in GitHub Desktop.
# Stop using callback, alternative is async
# http://webapplog.com/seven-things-you-should-stop-doing-with-node-js/?utm_source=nodeweekly&utm_medium=email
async.series [
(callback)->
# Find store based on store property returned from xml
Store.model.findOne({id: 'hstern'}).exec (err, store)->
callback err, store
(callback)->
console.log results
# Create mongoose products (check xml format) in this loop
product = new Product.model
id: itemObject.name[0]
ids:
'pt-br': itemObject.name[0]
'en-us': itemObject.name[1]
name:
'pt-br': itemObject.name[0]
'en-us': itemObject.name[1]
description:
'pt-br': itemObject.description[0]
'en-us': itemObject.description[1]
price: itemObject.price
productId: itemObject.productId
category: itemObject.category
store:
name: store.name
id: store.id
images:
gallery: []
thumb: ''
extraInfo:
'pt-br': itemObject.description[0]
'en-us': itemObject.description[1]
date:
created: new Date
callback null, 'shoryuken'
], (err, results)->
throw err if err
console.log results
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment