Write a Heroku Scheduler batch for MangoDB+Salesforce with Node.js

In previous post,I had shared how to 《Access Salesforce data via APIs(JSForce) from Outside Service》.
In this post I will share about how to write a Heroku Scheduler batch for synchronizing MangoDB data to Salesforce with Node.js, like the below outline picture.
MangoDB+Salesforce ※I have no doubt that there have many ways to do connect between MangoDB and Salesforce, such as 《 Lightning Connect Custom Adapters and MongoDB》By Enrico Murru and 《 Powering Salesforce Lightning Connect with MongoDB》, and I will try and share that in next posts separately.
Here we go.

1. In Salesforce

The Data Model

New a custom object named “MangodbObject” for storing MangoDB data. MangodbObject

2. In Cloud9 IDE

Update package.json

Add async, moment and mongoose to package.json file.

Create batch files

Create “db.js” and “sfdc.js” in root directory with the blow source code.

Depoly to Heroku

Depoly changed files to Heroku as the previous post,《Awesome Node.js development environment with Heroku and Cloud9

3. In Heroku

Add Add-ons

Add MangoLab and Heroku Scheduler to Heroku. Add-ons

Prepare test data of MongoDB

Create a collection named “accounts” and add the following data in MongoLab.

Add new job in Heroku Scheduler

Heroku Scheduler

4. Results

Heroku logs

Check Heroku logs with Heroku command “heroku logs”.

Data in Salesforce

MangoDBObject   Salesforce Now we have a batch which synchronizes data everyday from MangoLab to Salesforce. ;)
Enjoy it.

Related Post

Setup an awesome Salesforce developer environment ... Why Sublime Text 3 ? I've been working with Force.com for about 2 years, and always using Eclipse+Force.com IDE(See here, Eclipse Force.com IDE Installation)as my development environment. I don't think it is difficult to use, but it could more friendly. For example: 1. It doesn't support APEX an...
Write Apex Test Classes efficiently with Tesforce 1.Why Tesforce The Test Classes are required to deploy Apex to a production environment or to be packaged and placed on Force.com AppExchange, it must provide at least 75% code coverage. That will be a huge workload to SFDC Developers if the project(application) include a lot of Apex Classes,the...
Salesforce Mass Editor (Chrome Extension) – ... This's my second Chrome Extension (First one is HERE) this year, named "Salesforce Mass Editor" and it supports for doing the below things : ・Makes any Salesforce list view to be a powerful mass editor. ・Mass insert, mass clone, mass update, mass delete, ALL-IN-ONE. ・Export record data to CSV fi...
KISS principle for apex code with List and Map in ... Here are some KISS (Keep it simple, stupid) principles for cleaning our apex code with List and Map in Salesforce, as Linus Torvalds said: "Talk is cheap. Show me the code", let me show you as below: Initialize Map Normal https://gist.github.com/xgeek-net/cb98cf43ef51a72abf3fac01a141f381 KIS...

Post Tagged with , , , ,