db.cloud.roles
Retrieve the list of available roles for your application. Roles can be imported using the cli and then consumed by the application using this property.
The property is an observable. See Examples below for how to consume it.
Roles can be used when sharing data with other users by adding an entry into the members table and set the roles attribute of the member.
Type
Observable of Role[]
Example (React)
import { useObservable } from "dexie-react-hooks";
import { db } from "./db.js";
function MyComponent() {
const roles = useObservable(db.cloud.roles);
return (
<>
<h1>Roles</h1>
<ul>
{roles.map((role) => (
<li key={role.id}>{role.displayName}</li>
))}
</ul>
</>
);
}
This component would render the current roles
See useObservable()
Example (Svelte)
<script>
import { db } from "./db.js";
let oRoles = db.cloud.roles;
</script>
<div>
<h1>Roles</h1>
{#each $oRoles as role (role.id)}
<li>{role.displayName}</li>
{/each}
</div>
See Also
Dexie Cloud Docs
- Access Control in Dexie Cloud
- Add demo users
- Add public data
- Authentication in Dexie Cloud
- Consistency in Dexie Cloud
- DBPermissionSet
- Dexie Cloud API
- Dexie Cloud CLI
- Dexie Cloud Docs
- Dexie Cloud REST API
- DexieCloudOptions
- Invite
- Limits
- Member
- PersistedSyncState
- Purchase Subscription
- Realm
- Role
- Run Dexie Cloud on Own Servers
- Sharding and Scalability
- SyncState
- UserLogin
- db.cloud.configure()
- db.cloud.currentUser
- db.cloud.currentUserId
- db.cloud.events.syncComplete
- db.cloud.invites
- db.cloud.login()
- db.cloud.logout()
- db.cloud.options
- db.cloud.permissions()
- db.cloud.persistedSyncState
- db.cloud.roles
- db.cloud.schema
- db.cloud.sync()
- db.cloud.syncState
- db.cloud.userInteraction
- db.cloud.usingServiceWorker
- db.cloud.version
- db.cloud.webSocketStatus
- db.members
- db.realms
- db.roles
- dexie-cloud-addon