Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm not quite clear what you're asking, but if you're looking for where records get added to their appropriate <code>commitDetails</code> set, I believe <a href="https://github.com/emberjs/data/blob/83f9f6b9124612d3ac0b8ab34ad98b6028800138/packages/ember-data/lib/system/transaction.js#L179" rel="nofollow">this</a> is the line you're looking for, in the <code>commitDetails</code> property itself.</p> <p>Here's the relevant code.</p> <pre><code>forEach(records, function(record) { if(!get(record, 'isDirty')) return; record.send('willCommit'); var adapter = store.adapterForType(record.constructor); commitDetails.get(adapter)[get(record, 'dirtyType')].add(record); }); </code></pre> <p>Let's walk through it.</p> <pre><code>forEach(records, function(record) { if(!get(record, 'isDirty')) return; </code></pre> <p>The above says, for each record in the transaction, if it's not dirty, ignore it.</p> <pre><code>record.send('willCommit'); </code></pre> <p>Otherwise, update its state to inFlight.</p> <pre><code>var adapter = store.adapterForType(record.constructor); </code></pre> <p>Get the record's adapter.</p> <pre><code>commitDetails.get(adapter) </code></pre> <p>Look up the adapter's created/updated/deleted trio object, which was instantiated at the top of this method <a href="https://github.com/emberjs/data/blob/83f9f6b9124612d3ac0b8ab34ad98b6028800138/packages/ember-data/lib/system/transaction.js#L164-L168" rel="nofollow">here</a>. It's simply an object with the 3 properties created, updated, and deleted, whose values are empty OrderedSets.</p> <pre><code>[get(record, 'dirtyType')] </code></pre> <p>Get the appropriate OrderedSet from the object we just obtained. For example, if the record we're on has been updated, <code>get(record, 'dirtyType')</code> will return the string <code>updated</code>. The brackets are just standard JavaScript property lookup, and so it grabs the updated OrderedSet from our trio object in the previous step.</p> <pre><code>.add(record); </code></pre> <p>Finally, add the record to the OrderedSet. On subsequent iterations of the loop, we'll add other records of the same type, so all created records get added to one set, all updated records get added to another set, and all deleted records get added to the third set.</p> <p>What we end up with at the end of the entire method and return from the property is a Map whose keys are adapters, and whose values are these objects with the 3 properties created, updated, and deleted. Each of those, in turn, are OrderedSets of all the records in the transaction that have been created for that adapter, updated for that adapter, and deleted for that adapter, respectively.</p> <p>Notice that this computed property is marked <code>volatile</code>, so it will get recomputed each time that someone gets the <code>commitDetails</code> property.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload