How to use the realm.Permissions function in realm

To help you get started, we’ve selected a few realm examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github realm / my-first-realm-app / react-native / Permissions / ToDo / src / components / ProjectList.js View on Github external
realm.write(() => {
      // Create a project
      const project = realm.create("Project", {
        projectId: uuid(),
        owner: user.identity,
        name: projectName,
        timestamp: new Date()
      });

      // Fetches the system 
      const permissionUser = realm.objects("__User").filtered(`id == '${user.identity}'`)[0];

      // Create permission
      const permission = realm.create(Realm.Permissions.Permission, {
        role: permissionUser.role,
        canRead: true,
        canUpdate: true,
        canDelete: true,
      })

      // Add permission to project
      project.permissions.push(permission);

    });
    // Reset the state
github realm / realm-js / tests / js / permission-tests.js View on Github external
let config = (user) => {
            return {
                schema: [
                    {
                        name: 'Object',
                        properties: {
                            value: 'int',
                            permissions: '__Permission[]'
                        }
                    },
                    Realm.Permissions.Permission,
                    Realm.Permissions.User,
                    Realm.Permissions.Role,
                ],
                sync: {user, url: realmUrl, fullSynchronization: false}
            };
        };
        const owner = await Realm.Sync.User.login('http://127.0.0.1:9080', Realm.Sync.Credentials.usernamePassword(global.testAdminUserInfo.username, global.testAdminUserInfo.password));
github realm / realm-js / tests / js / permission-tests.js View on Github external
.then(realm => {
            let roles = realm.objects(Realm.Permissions.Role).filtered(`name = '__User:${realm.syncSession.user.identity}'`);
            TestCase.assertEqual(roles.length, 1);

            realm.write(() => {
                const permission = realm.create(Realm.Permissions.Permission,
                    { canUpdate: true, canRead: true, canQuery: true, role: roles[0] });

                let room = realm.create(PrivateChatRoomSchema.name, { name: `#sales_${Utils.uuid()}` });
                room.permissions.push(permission);
            });

            return waitForUpload(realm);
        })
        .then(realm => {