Realm object permissions on node


#1

I get this error when I run the below code (from docs)

message:“Schema validation failed due to the following errors:\n- Property ‘Person.permissions’ of type ‘array’ has unknown object type ‘__Permission’”

const PersonSchema = {
    name: 'Person',
    properties: {
        name: 'string',
        permissions: '__Permission[]'
    }
};

#2

what does your sync configuration look like when opening up the Realm? It’d be great if you could provide a more full code snippet

It looks like you are probably combining the full sync and query-based sync APIs.


#3
const PersonSchema = {
  name: 'Person',
  properties: {
      name: 'string',
      permissions: '__Permission[]'
  }
};

let AUTH_URL = "http://0.0.0.0:9080"
let syncServerURL = "realm://0.0.0.0:9080/Public"

Realm.Sync.User.login(AUTH_URL, 'realm-admin', 'password').then(user => {
    console.log("logged in as "+user.identity+" isAdmin "+user.isAdmin)
    const config = {
        sync: { 
          user: user,
          url: syncServerURL,
          partial: true,
        },
        schema: [PersonSchema]

      };
      let realm = new Realm(config);
}).catch(error => {
    console.error(error)
});

Also tried

    var realm = Realm.open(config)

#4

I’m getting exactly the same. Any update on this? Did you get it working?


#5

To anyone that finds this thread. You need to add the realm objects to you schema…

const AddressSchema = {
  name: 'Address',
  primaryKey: '_id',
  properties: {
    _id: 'string',
    permissions: '__Permission[]',
  },
}

let schema = [
  AddressSchema,
  Realm.Permissions.Permission,
  Realm.Permissions.User,
  Realm.Permissions.Role,
]
...
Realm.open({
  schema: schema,
  sync: {
    url: url,
    user: user,
    fullSyncronization: false
  }
})