Modify the application and republish to Bluemix

With the application deployed from your development workstation, you will now make a simple change to the application and then republish it to Bluemix.

  1. In a text editor, open the file app.js and modify the name of the file, the file description, and the values (lines 344, 345, and 348):
    • Line 354: Change the docName from ‘sample_doc’ to ‘test_doc’
    • Line 355: Change the docDesc from ‘A sample Document’ to ‘A test Document’
    • Line 358: Change the value from ‘A sample Document’ to ‘A test Document’
    352 // push sample data
    353 // save doc
    354 var docName = 'test_doc';
    355 var docDesc = 'A test Document';
    356 db.insert({
    357 name: docName,
    358 value: 'A test Document'
    359 }, '', function(err, doc) {
    360 if (err) {
    362 console.log(err);
    362 } else {
  2. Save the file after you make the updates.
    When the application starts, it creates a sample document in the database where uploaded files are saved as attachments. You just modified the code that creates this document in the database. Now, you will delete the document from the database and then restart the application to allow the database to be populated with the modified document.
  3. Open your application dashboard and click the Cloudant service shown in the Connections page.
  4. Access the Cloudant dashboard by clicking LAUNCH.
  5. Click the database icon on the left pane to open the Your Databases view.
  6. Click my_sample_db to open the database with the sample document.
  7. Edit the database document by clicking the pencil icon.
  8. Delete the document by clicking the trash icon.
  9. Confirm the deletion.
  10. Redeploy the updated application with the bx app push command. This time, you don’t need to include the --no-startor -m parameters.
    $ bx app push favapp-tor-0517 -c "node app.js" --no-manifest
  11. Open the application. You should now see the name test_doc for the automatically created document.
  12. To clean things up, delete the application and then the service by running these two commands. The -r parameter in the first command removes any mapped application routes.
    $ bx app delete favapp-tor-0517 -r
    $ bx service delete myCloudantDB
  13. Return to the Bluemix dashboard to confirm that the application and the service were removed.