Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. var DBItem = require('Fallback.DBItem');
  2. DBItem.getDataBase().items.count().then(function(count)
  3. {
  4. console.log('initial count: ' + count);
  5. var offset = 0
  6. , promiseArray = [];
  7.  
  8. while(offset < count)
  9. {
  10. DBItem.getDataBase().items.offset(offset).limit(100).toArray().then(bulkPutItems);
  11. offset += 100;
  12. }
  13.  
  14. }).catch(console.log)
  15.  
  16. function bulkPutItems(items)
  17. {
  18. items = _.map(items, function(item)
  19. {
  20. item.internalid = item.internalid + '_2';
  21. return item;
  22. });
  23. return DBItem.getDataBase().items.bulkPut(items).then(console.log);
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement