Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use promise #12

Closed
francophongvu opened this issue Oct 4, 2018 · 1 comment
Closed

How to use promise #12

francophongvu opened this issue Oct 4, 2018 · 1 comment

Comments

@francophongvu
Copy link

Hi,

Sorry if this question is stupid, but does this library support Promise? How to use it

Thanks

@enGMzizo
Copy link
Owner

function promiseCopy(data) {
  return new Promise((resolve, reject) => {
    copy(data, function (err, result) {
      if (err) {
        return reject(err)
      }
      resolve(result)
    })
  })
}

promiseCopy({
  source: {
    tableName: 'source_table_name', // required
  },
  destination: {
    tableName: 'destination_table_name', // required
  },
  log: true, // default false
  create: true // create destination table if not exist
}).then(function (results) {
  // do stuff
}).catch(function (err) {
  //handle error
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants