These are chat archives for orbitjs/orbit.js

29th
Dec 2017
Gregory M Kohler
@gmkohler
Dec 29 2017 00:39
Manually adding the inverse relationship to the indexeddb source after letting the data syncing do the rest of the work seems like a workaround but not one that is very scalable:
  async createCardPunch(attributes, workDayId) {
    const coordinator = this.get('dataCoordinator');

    const store = coordinator.getSource('store');
    const local = coordinator.getSource('local');

    const cardPunch = await store.update(t => [
      t.addRecord({
        type: 'cardPunch',
        attributes,
        relationships: {
          workDay: {
            data: {
              type: 'workDay',
              id: workDayId
            }
          }
        }
      })
    ]);

    await local.push(t => t.addToRelatedRecords(
      {
        type: 'workDay',
        id: workDayId
      },
      'cardPunches',
      {
        type: 'cardPunch',
        id: cardPunch.id
      }
    ));

    return cardPunch;
  },
Dan Gebhardt
@dgeb
Dec 29 2017 13:00
@gmkohler Thanks for reporting this. I think I understand what's going on internally. Essentially, the indexeddb source needs further awareness of inverse relationships to be able to guarantee that they are maintained in the same way that the store's cache maintains them. Could you please open an issue on the orbit repo? I'll need some time to consider the best way to handle this.
Gregory M Kohler
@gmkohler
Dec 29 2017 17:55
@dgeb thanks for the response! Sure thing.
Dan Gebhardt
@dgeb
Dec 29 2017 19:34
@gmkohler I see #476 was started a couple hours ago but doesn't have details yet. The details from above (or similar) would be fine when you get a chance. Thanks!
Gregory M Kohler
@gmkohler
Dec 29 2017 19:35
@dgeb Got caught in a couple of meetings after accidentally submitting--filling out now
Okay to use ember-orbit-specific API stuff in the description?
Dan Gebhardt
@dgeb
Dec 29 2017 19:35
ah perfect - thanks again :)
yeah, you can leave it ember-orbit specific if that's easier
still better to file it here where the underlying problem is
Gregory M Kohler
@gmkohler
Dec 29 2017 19:39
👍