Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Edited: Upon interchange below, this seems to be a schema and updating issue. Question may become something like: I have some entries in an array, and the ordinal index to those entries relates to some other arrays as well. How do I perform deletes without having mismatches?</p> <p>Three off the top possibilities occur, depending on frequency in the real world vs QA test scenarios. </p> <ol> <li>Consider adding a deleted flag but keeping the records in the same order. If someone toggles, reuse the same record, but fix however you want. </li> <li>Use an associative array (JS object) for each element (not a feature from relational world.) If you need an order, add an array that lists the keys in order. Both have syntax to update without touching anything other that what has changed, and will not overwrite changes to different fields.</li> <li><p>Use an associative array where the keys are numbers. Actual deletion won't hurt retrieval.</p> <p>stuff = {} stuff[1] = {some:'details'} stuff[2] = {some:'details2'}</p></li> </ol> <p>Was 1) Are you making changes to the same field? Make that into an array, and push changes, and pop the latest to read the current value.</p> <p>2) Are you changing different fields, but data is getting trounced? Then there is better syntax to use for the updating. you can update field by field.</p> <pre><code>$set: { 'fielda': 'valuea' } </code></pre> <p>won't lose edits on previous fields</p> <p>3) change your schema</p> <p>4) change the timing on the processes so they don't overlap. Or so they do so in smaller subsets, that you can manage to prevent from overlapping.</p> <p>I'd like to know, just out of interest, what multiple processes are needed to make updates on the same record? I don't work with anything that looks like that.</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. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. COThe client is an ipad client, and it is sending down multiple changes at one tie. We have built the items the client owns into the user collection, as we are often changing both info about the user and the things they have created at the same time. The document has a number of subdocuments. It makes it a lot safer for updates then splitting it up. In this case in particular, it's the credentials from various external services - they may decide to drop some on login. The client is sending them out concurrently rather than one after the other. We may send them as a single array.
      singulars
    2. COThe use case of dropping existing credentials need not have a cross-update conflict - they are distinct at some point in the user record. It sounds like you are performing an update of that field too high in the tree. Show us the update and it's a quick fix.
      singulars
    3. COHi, Jim, yes we are saving the entire user object. The credentials are in an array, and then the objects they are associated with are in another array. We are currently manipulating those arrays, then updating the user object, then resaving the entire user object. This might not be the best strategy overall, from what you're saying. However, because they are arrays, and we are deleting members, can I delete a single member in an array? We also like to compress the arrays when done, so that we have contiguous numbering, rather than leaving gaps. So, the numbering could change between saves.
      singulars
 

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