SHARE
TWEET

Untitled

a guest Jun 26th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. async function _prepareDetails(activityId, dealId) {
  2.  
  3. var offerInfo;
  4. var details = [];
  5.  
  6.  
  7. client.connect(function(err) {
  8.     assert.equal(null, err);
  9.     console.log("Connected correctly to server");
  10.  
  11.     const db = client.db(dbName);
  12.     const offers_collection = db.collection('collection_name');
  13.  
  14.     await offers_collection.aggregate([
  15.         { "$match": { 'id': Id} },
  16.     ]).toArray(function(err, docs) {
  17.         assert.equal(err, null);
  18.         console.log("Found the following records");
  19.         details = docs;
  20.     });
  21. })
  22. return details;
  23. }
  24.  
  25. app.post('/getDetails',(request,response)=>{
  26.  
  27. var Id = request.body.Id;
  28. var activityId = request.body.activityId;
  29. _prepareDetails(activityId,Id).then(xx => console.log(xx));
  30. response.send('xx');
  31. })
  32.      
  33. function _prepareDetails(activityId, dealId) {
  34.  
  35. var offerInfo;
  36. var details = [];
  37.  
  38.  
  39. client.connect(async (err) => {
  40.     assert.equal(null, err);
  41.     console.log("Connected correctly to server");
  42.  
  43.     const db = client.db(dbName);
  44.     const offers_collection = db.collection('collection_name');
  45.  
  46.     await offers_collection.aggregate([
  47.         { "$match": { 'id': Id} },
  48.     ]).toArray(function(err, docs) {
  49.         assert.equal(err, null);
  50.         console.log("Found the following records");
  51.         details = docs;
  52.     });
  53. })
  54. return details;
  55. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top