baskUpDoc.coffee 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/usr/bin/coffee
  2. 'use strict'
  3. PouchDB = require 'pouchdb'
  4. path = require('path')
  5. globalThis.pass = ()=>([1e4]+'').replace(/[018]/g,c=()->(c^crypto.getRandomValues(new Uint8Array(1))[0]&15 >> c/4).toString(16))
  6. globalThis.md5 = require 'md5'
  7. basePatch = 'https://oleg:631074@couchdb.osvoj.ru:443/000SitesScript/'
  8. db = new PouchDB(basePatch, {auto_compaction: true});
  9. c= []
  10. #84832606810
  11. test = ()->
  12. #console.dir c
  13. if c.length > 0
  14. a = c.shift()
  15. console.log '============ start ============'
  16. console.dir a
  17. db.get a.id, { open_revs:"all", attachments: true }
  18. .then (d)->
  19. console.dir d
  20. #path.exists 'backUp/'+a.id+'.json', (exists)->
  21. # if exists
  22. # dr = require 'backUp/'+a.id+'.json'
  23. # if d._rev != dr.ok._rev
  24. # else
  25. fs.writeFile './base/'+a.id+'.json', JSON.stringify(d), 'utf8', (a)->
  26. console.dir a
  27. test()
  28. fs = require('fs')
  29. upl = ()->
  30. db.allDocs()
  31. .then (d)->
  32. c = d.rows
  33. test()
  34. fs.writeFile '../base.json', JSON.stringify(d), 'utf8', (a)->
  35. console.dir a
  36. upl()