{"version":3,"sources":["jsdelivr-header.js","/npm/documentdbexport_timestamp@1.0.5/index.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,ACLA,IAAI,eAAiB,QAAQ,cAAc,eACvC,MAAQ,QAAQ,SAGhB,iBAAmB,SAAS,EAAU,EAAK,EAAU,EAAY,GAGnE,IAAI,GAAQ,IAAI,MAAO,UAGnB,EAAS,IAAI,eAAe,EAAU,CAAE,UAAW,IAGnD,EAAW,KACX,EAAI,EACJ,EAAiB,OAAS,EAAW,UAAY,EACjD,EAAW,EAAO,eAAe,GAGrC,MAAM,SAAQ,SAAS,GAGrB,EAAS,UAAS,SAAS,EAAK,GAG1B,WAGK,EAAQ,aACR,EAAQ,oBACR,EAAQ,aACR,EAAQ,KACf,EAAQ,IAAM,EAAQ,GACtB,EAAQ,UAAY,EAAQ,WACrB,EAAQ,UACR,EAAQ,IACf,IAGA,QAAQ,IAAI,KAAK,UAAU,KAE7B,EAAW,EACX,EAAG,KAAM,KACX,GACF,IAAE,WAEA,YAAoB,IAAb,CACT,IAAG,SAAS,EAAK,GAGf,IAAI,GAAM,IAAI,MAAO,UACrB,EAAS,EAAK,CAAE,QAAS,EAAG,MAAO,EAAM,GAAO,KAClD,GACF,EAEA,OAAO,QAAU,CACf,iBAAkB","file":"/npm/documentdbexport_timestamp@1.0.5/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/documentdbexport_timestamp@1.0.5/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","\r\nvar documentClient = require('documentdb').DocumentClient;\r\nvar async = require('async');\r\n\r\n// export a whole collection\r\nvar exportCollection = function(endpoint, key, database, collection, callback) {\r\n\r\n  // record start time\r\n  var start = new Date().getTime();\r\n\r\n  // initialise library\r\n  var client = new documentClient(endpoint, { masterKey: key });\r\n\r\n  // start the query\r\n  var lastItem = null;\r\n  var i = 0;\r\n  var collection_url = 'dbs/' + database + '/colls/' + collection;\r\n  var iterator = client.queryDocuments(collection_url);\r\n\r\n  // iterate through the collection\r\n  async.doUntil(function(cb) {\r\n\r\n    // retrieve the next item\r\n    iterator.nextItem(function(err, element) {\r\n\r\n      // if it's valid\r\n      if (element) {\r\n\r\n        // remove the DocumentDB special bits\r\n        delete element._etag;\r\n        delete element._attachments;\r\n        delete element._self;\r\n        delete element._rid;\r\n        element._id = element.id;\r\n        element.timestamp = element._ts;\r\n        delete element.id;\r\n        delete element._ts;\r\n        i++;\r\n\r\n        // output the JSON\r\n        console.log(JSON.stringify(element));\r\n      }\r\n      lastItem = element;\r\n      cb(null, null);\r\n    });\r\n  },function() {\r\n    // continue until we get 'undefined'\r\n    return lastItem === undefined;\r\n  }, function(err, results) {\r\n\r\n    // call the callback with a summary\r\n    var end = new Date().getTime();\r\n    callback(err, { records: i, time: (end - start)/1000})\r\n  });\r\n};\r\n\r\nmodule.exports = {\r\n  exportCollection: exportCollection\r\n}"]}