Method: Appwrite::Databases#create

Defined in:
lib/appwrite/services/databases.rb

#create(database_id:, name:) ⇒ Database

Create a new Database.

Parameters:

  • database_id (String)

    Unique Id. Choose a custom ID or generate a random ID with ‘ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can’t start with a special char. Max length is 36 chars.

  • name (String)

    Collection name. Max length: 128 chars.

Returns:

  • (Database)


46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/appwrite/services/databases.rb', line 46

def create(database_id:, name:)
    path = '/databases'

    if database_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
    end

    if name.nil?
      raise Appwrite::Exception.new('Missing required parameter: "name"')
    end

    params = {
        databaseId: database_id,
        name: name,
    }
    
    headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'POST',
        path: path,
        headers: headers,
        params: params,
        response_type: Models::Database
    )
end