Importing API Data into LSAdapter managed Store

Anyone kind enough to lend a few thoughts will earn my undying admiration.

I have a scenario where I’m importing records from a third party API and need to push the records into LocalStorage using the LSAdapter.

This essentially means manually establishing any relationships by working my way down the dependency tree, and for the most part this works just fine with one caveat: I need to wait for all records of a given type to finish saving otherwise it appears the save queue gets flushed out.

In the crude example below, the first two of type “device” get dropped completely, but all of the last record type (“room”) do get saved. I’ve also noticed that this is only an issue when the adapters for each are in the same namespace.

The question I have is can I push an array of records into the store with one method so I can chain with promises?

Or am I just going about this the wrong way completely? It would be great if I could somehow use serializers and adapters to map data initially, but after that I really just want to maintain it in LocalStorage.

      device = devices[0]
      alldevices = self.store.all 'device'
      devicerecord = self.store.createRecord 'device', 
                name: device.name
                deviceId: device.id
      devicerecord.save()

      device = devices[1]
      devicerecord = self.store.createRecord 'device', 
                name: device.name
                deviceId: device.id
      devicerecord.save()

      room = rooms[0]
      allrooms = self.store.all 'room'
      roomrecord = self.store.createRecord 'room', 
                name: room.name
                roomId: room.id
      roomrecord.save()

      room = rooms[1]
      allrooms = self.store.all 'room'
      roomrecord = self.store.createRecord 'room', 
                name: room.name
                roomId: room.id
      roomrecord.save()

Upon further review this was the result of a localstorage adapter that would only load existing data on “init” not on update or create, which proved problematic when systematically creating new records (rather than using dedicated views)