Realmdb React Native - Empty objects in Realmdb, when creating and listing objects

Asked

Viewed 44 times

1

Whoa, guys, all right? I’m having a problem with my Realmdb here, I’m trying to create a new object and trying to list these created objects. However, when listing or creating, it returns empty objects to me. Follow the example:

Example of use:

const Store = {
    name: 'Store',
    properties: {
        storeId: {type: 'int'},
        storeName: {type: 'string'}
    }
};

export default new Realm({schema: [Store], schemaVersion: 20});

Here, when I write, it already returns to me an empty object. However it adds...

 realm.write(() => {
     realm.create('Stores', {storeId: 1, storeName: "My Store"});
 });

When I try to read

 let stores = realm.objects('Stores');

I get that

[{}]

OBS: I tried to list these objects in a component, but it still has no data.

  • realm.objects('Stores')) one ) plus, it was a clerical error?

  • Misspelled here, I opened the Remake. But it gave the same problem yet.

1 answer

-2

Instead:

let stores = realm.objects('Stores'))

Try it this way:

let stores = realm.objects('Stores')
  • Oops, I ended up writing wrong here. But I tried too, same problem yet :(

Browser other questions tagged

You are not signed in. Login or sign up in order to post.