createDatabase method

Future<ResultResponse<bool>> createDatabase(
  1. CreateDatabaseInfo databaseInfo
)

Creates a database. The data with these properties is required:

name: Has to contain a valid database name. users: Has to be an array of user objects to initially create for the new database.

User information will not be changed for users that already exist. If users is not specified or does not contain any users, a default user root will be created with an empty string password. This ensures that the new database will be accessible after it is created. Each user object can contain the following attributes:

username: Login name of the user to be created passwd: The user password as a string. If not specified, it will default to an empty string. active: A flag indicating whether the user account should be activated or not. The default value is true. If set to false, the user won’t be able to log into the database. extra: A JSON object with extra user information. The data contained in extra will be stored for the user but not be interpreted further by ArangoDB. https://www.arangodb.com/docs/devel/http/database-database-management.html#create-database

Implementation

Future<ResultResponse<bool>> createDatabase(
    CreateDatabaseInfo databaseInfo) async {
  final info = {
    'name': databaseInfo.name,
    'users': databaseInfo.databaseUsers
        .map((u) => {
              'username': u.username,
              'passwd': u.password,
            })
        .toList()
  };

  return _toResultResponse(
      await _httpPost(['_db', db, '_api', 'database'], info));
}