title: React-Native Realm DB - exception only in debug mode upon insertion: "_id field must be of type 'uuid', got 'object' ([object Object])"
body: <p>I am building a <code>React-Native</code> app that uses <code>Realm DB</code> as the underlying database.</p>
  <p>While implementing basic insertion methods I encountered exceptions when attempting to insert a new object with a unique identifier - while using <code>UUID/ObjectId</code> (same issue when using one or the other).</p>
  <p><strong>The weird thing is - when running in release mode - the exception disappears - and the insertion is successful!</strong></p>
  <p>Error log in debugger (both Metro and vscode debugger):</p>
  <pre><code>EconomeApp ERROR Log Start Fri Aug 26 2022 17:41:44 GMT+0300 (Israel Daylight Time)
  Realm write ERROR: Error: CreditCard._id must be of type 'uuid', got 'object' ([object Object])
  stack:
  create@[native code]
  anonymous@[native code]
  write@[native code]
  EconomeApp ERROR Log End
  </code></pre>
  <p>log in release mode:</p>
  <pre><code> LOG  Running &quot;EconomeApp&quot; with {&quot;rootTag&quot;:61}
   LOG  EconomeApp Log Start Fri Aug 26 2022 17:47:25 GMT+0300 (IDT)
  created one card: d6ce1d14-0dc0-43db-8b6b-c4f04f85aa41
  EconomeApp Log End
   LOG  EconomeApp Log Start Fri Aug 26 2022 17:47:25 GMT+0300 (IDT)
  Realm written successfuly
  EconomeApp Log End
  </code></pre>
  <p>Realm init method:</p>
  <pre><code>async _updateCollectionStructures() {
          try {
              this._realmObject = await Realm.open({
                  path: Defenitions.databaseName,
                  schema: [CollectionTypes.Assets, CollectionTypes.Category, CollectionTypes.ConstantExpense, CollectionTypes.CreditCard,
                  CollectionTypes.DirectExpense, CollectionTypes.DynamicExpense, CollectionTypes.Income, CollectionTypes.Month, CollectionTypes.Preference,
                  DataStructures.ExpenseData, DataStructures.IncomeData, DataStructures.LimitationGoalData],
  
                  schemaVersion: Defenitions.databaseVersion,
  
                  migration: (oldRealm, newRealm) =&gt; {
                      //future development...
                  }
              });
          }
          catch (err) {
              console.error(&quot;Failed to open the realm db &quot;, err.message);
          }
      };
  </code></pre>
  <p>write method:</p>
  <pre><code>/**
       * Writes to database
       * 
       * need to provide a callback with documents creation
       * @param {CallableFunction} func 
       */
      _writeToDB(func) {
          this._checkAndthrowNotInitializedErr();
          try {
              this._realmObject.write(func);
              Helper.log(`Realm written successfuly`);
          }
          catch (e) {
              Helper.logErr(`Realm write ERROR: ` + e + '\n' + 'stack:\n' + e.stack);
          }
      }
  </code></pre>
  <p>CreditCard class:</p>
  <pre><code>export class CreditCard {
      /**
       * 
       * @param {Realm.BSON.UUID} id 
       * @param {Date} lastPaidDate 
       * @param {Realm.BSON.Decimal128} cardLimit 
       * @param {string} lastFourDigits 
       * @param {boolean} isManualPayment 
       * @param {Number} dayCycle 
       */
      constructor(id, lastPaidDate, cardLimit, lastFourDigits, isManualPayment, dayCycle)
      {
          this._id = id;
          this.lastPaidDate = lastPaidDate;
          this.cardLimit = cardLimit;
          this.lastFourDigits = lastFourDigits;
          this.isManualPayment = isManualPayment;
          this.dayCycle = dayCycle;
      }
  
      static schema = {
          name: &quot;CreditCard&quot;,
          primaryKey: '_id',
          properties: {
              _id: {type: &quot;uuid&quot;, default: new UUID()},
              lastpaidDate: { type: &quot;date&quot;, default: new Date() },
              cardLimit: { type: &quot;decimal128&quot;, default: Defenitions.undefinedDecimalValue },
              lastFourDigits: { type: &quot;string&quot;, default: Defenitions.undefinedString },
              isManualPayment: { type: &quot;bool&quot;, default: Defenitions.defaultManualPayment },
              dayCycle: { type: &quot;int&quot;, default: Defenitions.defaultDayCycle }
          },
      };
  }
  </code></pre>
  <p>the attempted insertion method: <strong>where the exception is thrown</strong></p>
  <pre><code>this._writeToDB(() =&gt; {
              let ob = new UUID();
              Helper.log(ob);
              let card1 = this._realmObject.create(CollectionTypes.CreditCard.schema.name, 
                  new CollectionTypes.CreditCard(new UUID(), new Date(), new Realm.BSON.Decimal128(&quot;123.5123&quot;), &quot;1234&quot;, false, 15));
              Helper.log(`created one card: ${card1._id}`);
          });
  </code></pre>