One model with multiple adapters


#1

So many times in my projects, I wind up having data models that have some attributes that need to be stored in a sql database and queried against and other attributes that are always changing in a real-time sense. An example of this would be say I’m trying to model a truck:

Truck = DS.Model.extend
  longitude: DS.attr "number"
  latitude: DS.attr "number"
  licensePlate: DS.attr "string"
  createdAt: DS.attr "date"
  company: DS.attr "string"

In this case, the licensePlate, createdAt, and company attributes are things that don’t really change but are queried against, therefore I’d like to use an ActiveModelAdapter and rails to store these attributes… however, longitude and latitude are attributes that are changing in real time, and I’d like to use a Firebase (or SocketIO) adapter to share that info across all the users.

Right now, I’m splitting up the model into a RailsTruck, a FireTruck with sometimes a MetaTruck to manage the varying adapters I need… but I’m wondering what is the ember cannon way of doing this? How do you guys handle data persistence for complex models that need to be split across multiple adapters to communicate with different vendors? (and the case for different vendors is because you’re poor as hell and can’t afford to pay firebase to store your data or heroku to share it).