1
1
let mongoose = require ( 'mongoose' )
2
2
const extend = require ( 'util' ) . _extend ;
3
- mongoose . set ( 'debug' , false ) ;
3
+ mongoose . set ( 'debug' , true ) ;
4
4
let ObjectId = require ( 'mongoose' ) . Types . ObjectId
5
-
6
5
const config = require ( 'config' )
7
6
7
+ let mongoDBConnection = config . get ( 'mongoDBConnection' )
8
+
9
+ let mongoURL = mongoDBConnection . URL
10
+ if ( process . env . mongoURL !== undefined && process . env . mongoURL !== '' ) {
11
+ mongoURL = process . env . mongoURL
12
+ }
13
+
14
+ // console.log("==========", mongoURL)
15
+ // `Job` here has essentially the same API as JobCollection on Meteor.
16
+ // In fact, job-collection is built on top of the 'meteor-job' npm package!
17
+ mongoose . Promise = global . Promise
18
+ // Connect to the beerlocker MongoDB
19
+ // mongoose.connect('mongodb://localhost:3001/meteor');
20
+ mongoose . connect ( mongoURL , { autoReconnect : true , bufferMaxEntries : 0 , reconnectInterval : 1000 , poolSize : 5 , reconnectTries : 30 , keepAlive : 800000 , connectTimeoutMS : 800000 } , function ( err , db ) {
21
+ if ( err ) {
22
+ console . log ( 'error.........' , err )
23
+ }
24
+ } )
25
+ // mongoose.connect('mongodb://obdev:123456@ds133311.mlab.com:33311/closeoutpromo');
26
+ let ObjSchema = mongoose . Schema
27
+
28
+
29
+
8
30
let elasticsearch = require ( 'elasticsearch' )
9
31
let rpRequest = require ( 'request-promise' )
10
32
let http = require ( 'http' )
@@ -13,7 +35,6 @@ let https = require('https')
13
35
const uuidV1 = require ( 'uuid/v1' ) ;
14
36
let ESuserData = null
15
37
let Promise = require ( 'es6-promise' ) . Promise
16
- let ObjSchema = mongoose . Schema ;
17
38
18
39
let rethink = require ( 'rethinkdb' )
19
40
let rethinkDBConnection = extend ( { } , config . get ( 'rethinkDBConnection' ) )
@@ -46,7 +67,7 @@ let activeSummary = []
46
67
let ESClient = new elasticsearch . Client ( {
47
68
host : esUrl ,
48
69
requestTimeout : 100000
49
- // ,log: 'trace'
70
+ // ,log: 'trace'
50
71
} )
51
72
let uploadedRecord = 0
52
73
@@ -337,7 +358,7 @@ async function makeNewPreviewUser (objWorkJob) {
337
358
338
359
339
360
function getUserDataFromMongo ( userid ) {
340
- let ObjMain = new ObjSchema ( { _id : 'string' } , { strict : false , 'collection' : 'users' } )
361
+ let ObjMain = new ObjSchema ( { _id : 'string' } , { strict : false , bufferCommands : false , 'collection' : 'users' } )
341
362
let modelOBUsers
342
363
let modelName = 'mdlUsers'
343
364
if ( mongoose . models && mongoose . models [ modelName ] ) {
@@ -1054,7 +1075,7 @@ function getUserNewVersion (ESUser) {
1054
1075
1055
1076
function makeDynamicCollectionObj ( collectionName ) {
1056
1077
collectionName = collectionName . charAt ( 0 ) . toUpperCase ( ) + collectionName . slice ( 1 ) . toLowerCase ( )
1057
- let ObjMain = new ObjSchema ( { _id : 'string' } , { strict : false , 'collection' : collectionPrefix + collectionName } )
1078
+ let ObjMain = new ObjSchema ( { _id : 'string' } , { strict : false , bufferCommands : false , 'collection' : collectionPrefix + collectionName } )
1058
1079
let modelName = 'mdl' + collectionName
1059
1080
if ( mongoose . models && mongoose . models [ modelName ] ) {
1060
1081
return mongoose . models [ modelName ]
@@ -1065,7 +1086,7 @@ function makeDynamicCollectionObj (collectionName) {
1065
1086
1066
1087
function makeDynamicCollectionObjWithoutPrefix ( collectionName ) {
1067
1088
// collectionName = collectionName.charAt(0).toUpperCase() + collectionName.slice(1).toLowerCase()
1068
- let ObjMain = new ObjSchema ( { _id : 'string' } , { strict : false , 'collection' : collectionName } )
1089
+ let ObjMain = new ObjSchema ( { _id : 'string' } , { strict : false , bufferCommands : false , 'collection' : collectionName } )
1069
1090
let modelName = 'mdl' + collectionName
1070
1091
if ( mongoose . models && mongoose . models [ modelName ] ) {
1071
1092
return mongoose . models [ modelName ]
@@ -1193,7 +1214,7 @@ function convertStringToArray (str, seprater) {
1193
1214
1194
1215
// to update user job queue process status to import_completed
1195
1216
function updateJobQueueStatus ( objWorkJob ) {
1196
- let objJobMaster = new ObjSchema ( { _id : String } , { strict : false , 'collection' : 'uploaderJobMaster' } )
1217
+ let objJobMaster = new ObjSchema ( { _id : String } , { strict : false , bufferCommands : false , 'collection' : 'uploaderJobMaster' } )
1197
1218
let mdlobjJobMaster = null
1198
1219
if ( mongoose . models && mongoose . models . objJobMaster ) {
1199
1220
mdlobjJobMaster = mongoose . models . objJobMaster
0 commit comments