How to use the immudb-node/dist/types/user.USER_PERMISSION.READ_ONLY function in immudb-node

To help you get started, we’ve selected a few immudb-node 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 codenotary / immudb-client-examples / node / user-management.ts View on Github external
(async () => {
  try {
    const loginReq: Parameters.Login = { user: IMMUDB_USER, password: IMMUDB_PWD }
    const loginRes = await cl.login(loginReq)
    console.log('success: login', loginRes)

    const createUserReq: Parameters.CreateUser = {
      user: randStr,
      password: 'Example12#',
      permission: USER_PERMISSION.READ_ONLY,
      database: 'defaultdb',
    }
    const createUserRes = await cl.createUser(createUserReq)
    console.log('success: createUser', createUserRes);

    const listUsersRes = await cl.listUsers()
    console.log('success: listUser', util.inspect(listUsersRes, false, 6, true))

    const changePermissionReq: Parameters.ChangePermission = {
      action: USER_ACTION.GRANT,
      username: randStr,
      database: randStr,
      permission: USER_PERMISSION.READ_WRITE, 
    }
    const changePermissionRes = await cl.changePermission(changePermissionReq)
    console.log('success: changePermission', changePermissionRes);