Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function Label(name, color) {
  2.     this.name = name;
  3.     this.color = color;
  4. }
  5.  
  6. var workLabel = new Label('work', 'red');
  7. var personalLabel = new Label('personal', 'red');
  8.  
  9. console.log(workLabel instanceof Label)
  10.  
  11. localforage.setItem(uuidv4(), workLabel).then(function (workLabel) {
  12.     console.log(workLabel);
  13. }).catch(function (err) {
  14.     console.log(err);
  15. })
  16.  
  17. localforage.setItem(uuidv4(), personalLabel).then(function (personalLabel) {
  18.     console.log(personalLabel);
  19. }).catch(function (err) {
  20.     console.log(err);
  21. })
  22.  
  23. localforage.iterate(function(value, key, iterationNumber) {
  24.     // Resulting key/value pair -- this callback
  25.     // will be executed for every item in the
  26.     // database.    
  27.     if (value instanceof Label) {
  28.         console.log("teste");
  29.         console.log([key, value]);
  30.     }    
  31. }).then(function() {
  32.     console.log('Iteration has completed');
  33. }).catch(function(err) {
  34.     // This code runs if there were any errors
  35.     console.log(err);
  36. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement