start.js
function(callback){
        var cursor = db.db(dbName).collection(collectionName).find({}).toArray(function(err,result){
            if(result.length!=0){
                roadmapNum = roadMapIdTemp = parseInt(result[result.length-1]['roadMapId'])+1;
            }
            else{
                roadmapNum = roadMapIdTemp = 1;
            }
            db.db(dbName).collection(collectionName).insertOne({
                "roadMapId" : roadMapIdTemp.toString(),
                "clientId" : source['clientId'],
                "orderNode" : source['orderNode'],
                "initNode" : source['initNode'],
                "lastNode" : source['lastNode'],
                "incomingNode" : source['incomingNode'],
                "outingNode" : source['outingNode'],
                "isInput" : source['isInput'],
                "isOutput" : source['isOutput'],
                "nodeIds" : source['nodeIds']
            },function(err, result){
                response.send(roadmapNum.toString());
            });
        });

    }
function(callback){
        var cursor = db.db(dbName).collection(collectionName).find({}).toArray(function(err,result){
            if(result.length!=0){
                roadmapNum = roadMapIdTemp = parseInt(result[result.length-1]['roadMapId'])+1;
            }
            else{
                roadmapNum = roadMapIdTemp = 1;
            }
            db.db(dbName).collection(collectionName).insertOne({
                "roadMapId" : roadMapIdTemp.toString(),
                "clientId" : source['clientId'],
                "orderNode" : source['orderNode'],
                "initNode" : source['initNode'],
                "lastNode" : source['lastNode'],
                "incomingNode" : source['incomingNode'],
                "outingNode" : source['outingNode'],
                "isInput" : source['isInput'],
                "isOutput" : source['isOutput'],
                "nodeIds" : source['nodeIds']
            },function(err, result){
                response.send(roadmapNum.toString());
            });
        });

    }
function ( callback ) { var cursor = db . db ( dbName ) . collection ( collectionName ) . find ( { } ) . toArray ( function ( err , result ) { if ( result . length != 0 ) { roadmapNum = roadMapIdTemp = parseInt ( result [ result . length - 1 ] [ 'roadMapId' ] ) + 1 ; } else { roadmapNum = roadMapIdTemp = 1 ; } db . db ( dbName ) . collection ( collectionName ) . insertOne ( { "roadMapId" : roadMapIdTemp . toString ( ) , "clientId" : source [ 'clientId' ] , "orderNode" : source [ 'orderNode' ] , "initNode" : source [ 'initNode' ] , "lastNode" : source [ 'lastNode' ] , "incomingNode" : source [ 'incomingNode' ] , "outingNode" : source [ 'outingNode' ] , "isInput" : source [ 'isInput' ] , "isOutput" : source [ 'isOutput' ] , "nodeIds" : source [ 'nodeIds' ] } , function ( err , result ) { response . send ( roadmapNum . toString ( ) ) ; } ) ; } ) ; }
run roadmap of save it to mongodb.
run roadmap of save it to mongodb .