Uploaded image for project: 'Realm JavaScript SDK'
  1. Realm JavaScript SDK
  2. RJS-656

Realm object constructor must not return another value

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None

      Goals

      Create a simple Realm App and saving some data.

      Expected Results

      After adding realm to project and config it, Saves data

      Actual Results

      Realm object constructor must not return another value
      <!--- What happened instead? -->
      <!--- e.g. the stack trace of a crash -->

      Steps to Reproduce

      1. Create a new React Native project
      2. add realm and lodash as dependencies
      3. add below codes

      Code Sample

      SaleTX.js

      import _ from 'lodash'
      
      class RealmBase {}
      RealmBase.prototype.refAsArray = function(ref) {
          return _.keys(this[ref]).map(key => this[ref][key])
      }
      class SaleTX extends RealmBase {
      	get json() {
      		let result = {
      			id: this.id,
      			merchantId: this.merchantId,
      		};
      
      		return result;
      	}
      }
      
      SaleTX.schema = {
      	name: 'SaleTX',
      	primaryKey: 'id',
      	properties: {
      		id: { type: 'string', indexed: true },
      		merchantId: { type: 'string', optional: true },
      	}
      };
      
      export { SaleTX };
      
      

      App.js

      import React from 'react';
      import {
        View
      }
      import Realm from 'realm';
      import { SaleTX } from './SaleTX';
      
      class App extends React.Component {
        constructor(props) {
          super(props);
        }
      
      componentDidMount (){
        const realm = new Realm({
          schema: [
            SaleTX,
          ],
        });
      
        let sale = realm.write(() => {
          realm.create('SaleTX', {
            merchantId: '54',
            id: '1'
          });
          
        });
      
      }
      
        render () {
          return(
            <View />
          )
      }
      }
      
      

      Version of Realm and Tooling

      • Realm JS SDK Version: 6.0.2
      • React Native: 0.62.2
      • Client OS & Version: Win 10 or Mac High Sierra

            Assignee:
            lubo.blagoev@mongodb.com Lubo Blagoev
            Reporter:
            unitosyncbot Unito Sync Bot
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: