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

undefined is not a function from Model Class functions

    • Type: Icon: Task Task
    • Resolution: Works as Designed
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: None

      How frequently does the bug occur?

      All the time

      Description

      Hello, after update realmJS from 10.12.0 to 11.1.0 i have problem with class functions.

      I have Model Class

      export class TradePointRealmModel extends Realm.Object {
        public objectId!: string;
        public extId!: string;
        public name!: string;
        public salerRoutes!: Realm.List<SalerRouteRealmModel>;
        public routeItems!: Realm.List<RouteItemRealmModel>;
      
        public static schema: Realm.ObjectSchema = {
          name: 'TradePoint',
          primaryKey: 'objectId',
          properties: {
            objectId: 'string',
            extId: { type: 'string', indexed: true },
            name: 'string',
            channelSaleId: 'string',
            channelSaleName: 'string',
            address1: 'string?',
            address2: 'string?',
            address3: 'string?',
            address4: 'string?',
            legalAddress: 'string?',
            streetAddress: 'string?',
            retailerId: 'string?',
            retailerName: 'string?',
            assortformat: 'string?',
            banner: 'string?',
            branchId: 'string?',
            branchName: 'string?',
            latitude: 'float?',
            longitude: 'float?',
            customer: 'string?',
            customerIsis: 'string?',
            rd: 'string?',
            rdIsis: 'string?',
            recDays: 'int?',
            recTimeBeg: 'string?',
            recTimeEnd: 'string?',
            recurrence: 'int?',
            segment: 'int?',
            timeInTt: 'int?',
            wasVisitThisMonth: 'int',
            fullAddress: 'string',
            searchNameAddress: 'string',
            internalSortId: 'float',
            salerRoutes: { type: 'linkingObjects', objectType: 'SalerRoute', property: 'tradePoint' },
            routeItems: { type: 'linkingObjects', objectType: 'RouteItem', property: 'tradePoint' },
          },
        } as TypedRealmObjectSchema;
      
        @computed
        get title() {
          return `${this.name}, ${this.fullAddress}`;
        }
      
        markAsSynced = () => {
          this.routeItems.forEach(ri => ri.markAsSynced());
        };
      
        toJSONWithGetters = () => {
          return {
            ...this.toJSON(),
            title: this.title,
            attributesText: this.attributesText,
          } as ITradePointRealmModelJsonWithGetters;
        };
      }
      

      This data correctly written in base

      this.realm.write(() => {
            this.realm.delete(this.tradePointsRaw);
            items.forEach((item, index) => {
              const fullAddress = createTradePointAddress(item);
              this.realm.create<ITradePointRealmInsertModel>(TradePointRealmModel.schema.name, {
                ...item,
                fullAddress,
                internalSortId: index + 1,
              });
            });
          });
      

      after i create list by type Realm.Results<TradePointRealmModel>;

      const objects = () => this.realm.objects(TradePointRealmModel);
      this.tradePointsRaw = objects();
      

      and after when i try get function by tradePointsRaw[0].markAsSynced i have the message "undefined is not a function", if i try get computed prop tradePointsRaw[0].title i got normal value ("TradePointOneAdress")

      In 10.12.0 Realm this call tradePointsRaw[0].markAsSynced is worked, and function called

      Stacktrace & log output

      No response

      Can you reproduce the bug?

      Yes, always

      Reproduction Steps

      No response

      Version

      11.1.0

      What SDK flavour are you using?

      Local Database only

      Are you using encryption?

      No, not using encryption

      Platform OS and version(s)

      IOS 16

      Build environment

      System:
      OS: macOS 12.6
      CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
      Memory: 252.61 MB / 16.00 GB
      Shell: 3.2.57 - /bin/bash
      Binaries:
      Node: 16.15.0 - /usr/local/bin/node
      Yarn: 1.22.5 - ~/.yarn/bin/yarn
      npm: 8.5.5 - /usr/local/bin/npm
      Watchman: 2022.06.06.00 - /usr/local/bin/watchman
      Managers:
      CocoaPods: 1.11.3 - /usr/local/bin/pod
      SDKs:
      iOS SDK:
      Platforms: DriverKit 21.4, iOS 16.0, macOS 12.3, tvOS 16.0, watchOS 9.0
      Android SDK: Not Found
      IDEs:
      Android Studio: Not Found
      Xcode: 14.0.1/14A400 - /usr/bin/xcodebuild
      Languages:
      Java: 11.0.4 - /usr/bin/javac
      npmPackages:
      @react-native-community/cli: Not Found
      react: 18.1.0 => 18.1.0
      react-native: 0.70.4 => 0.70.4
      react-native-macos: Not Found
      npmGlobalPackages:
      react-native: Not Found

      Which debugger for React Native: ..

      Cocoapods version

      No response

            Assignee:
            kraen.hansen@mongodb.com Kræn Hansen
            Reporter:
            unitosyncbot Unito Sync Bot
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: