title: Chaining together promises with a db insert
body: <p>I'm struggling trying to chain together three requests that require synchrony in node.js. Here is my attempt at using promises, but i am getting an error saying that db.run isn't a function. The first action should insert into my sqlite db. The most important thing i need is the
  this.lastID variable, which lists the id of the last enetered item. Before attempting to use promises, I was having trouble with scoping. This is important because i need to take this value and use use it in my JSON object under the callback key. Lastly, Im using the requests npm package to send the request. </p>
  
  <p>I am using the bluebird promises library, sqlite3 npm package, nodejs, express. </p>
  
  <p>Any help with this would be awesome because I'm lost.</p>
  
  <pre><code>function db() {
     return new Promise(function(resolve, reject) {
        db.run(`INSERT INTO scan_requests(name, date) VALUES(?,?);`,  [name,date], function(err) {
           if (err) {
              console.log(err)
           }
           let q = this.lastID
           resolve(q)
       })
     })
   }
  
  db()
     .then(function(q) {
        let options = {
           url: 'API',
           body: {
             name: req.name,
             scan_callback: `http://localhost:80/${q}` 
           },
           json: true
        }
        resolve(options)
     }).then(function(options) {
        console.log(options)
    })
  </code></pre>