0

I have a collection in my app which is contain this model list.

local data:

[
      {
        "level": "warning",
       "message": "test1"
      },
      {
        "level": "warning",
        "message": "test2"
      },
      {
        "level": "warning",
        "message": "test3"
      },
      {
        "level": "warning",
        "message": "test4"
      },
      {
        "level": "warning",
        "message": "test5"
      },
      {
        "level": "warning",
        "message": "test6"
      }
 ]

i am fetching collection every 2 minutes. And i want to collect only new added models as a new collection.

Is there any easy way to do this? Or i need to compare two lists after every fetch.

new data:

[
      {
        "level": "warning",
        "message": "test1"
      },
      {
        "level": "warning",
        "message": "test2"
      },
      {
        "level": "warning",
        "message": "test3"
      },
      {
        "level": "warning",
        "message": "test4"
      },
      {
        "level": "warning",
        "message": "test5"
      },
      {
        "level": "warning",
        "message": "test6"
      },
      {
        "level": "warning",
        "message": "test7"
      },
      {
        "level": "warning",
        "message": "test8"
      }
]

what i want

[
      {
        "level": "warning",
        "message": "test7"
      },
      {
        "level": "warning",
        "message": "test8"
      }
]

Excuse my english. Thank you.

Samed
  • 136
  • 1
  • 14
  • See http://stackoverflow.com/questions/13147278/using-underscores-difference-method-on-objects – Yura Sep 24 '14 at 13:37
  • So there is no an easy way at backbone? @Yura – Samed Sep 25 '14 at 11:20
  • While you can try to find the difference between two arrays, you could instead add `timestamp` property to your objects to check the starting point after which you get new objects to be added to your interface. – Yura Sep 25 '14 at 11:37

0 Answers0