Laravel Forge JavaScript SDK

Databases

Databases

Create a database

Method

forge.database.create(server_id, payload)

Usage

1const forge = new Forge('API_TOKEN');
2
3const database = await forge.database.create(server_id, payload);

Payload

1{
2 name: 'forge',
3 user: 'forge',
4 password: 'dolores'
5}

Payload Parameters

KeyDescription
nameThe name of the database.
userThis field is optional. If passed, it will be used to create a new Database User with access to the newly created database.
passwordThis field is only required when a user value is given.

Example Response

1{
2 "database": {
3 "id": 1,
4 "name": "forge",
5 "status": "installing",
6 "created_at": "2016-12-16 16:12:22"
7 }
8}

Sync database

Method

forge.database.sync(server_id)

Usage

1const forge = new Forge('API_TOKEN');
2
3await forge.database.sync(server_id);

List databases

Method

forge.database.list(server_id)

Usage

1const forge = new Forge('API_TOKEN');
2
3const databases = await forge.database.list(server_id);

Example Response

1{
2 "databases": [
3 {
4 "id": 1,
5 "name": "forge",
6 "status": "installing",
7 "created_at": "2016-12-16 16:12:22"
8 }
9 ]
10}

Get a database

Method

forge.database.get(server_id, database_id)

Usage

1const forge = new Forge('API_TOKEN');
2
3const database = await forge.database.get(server_id, database_id);

Example Response

1{
2 "database": {
3 "id": 1,
4 "name": "forge",
5 "status": "installing",
6 "created_at": "2016-12-16 16:12:22"
7 }
8}

Delete a database

Method

forge.database.delete(server_id, database_id)

Usage

1const forge = new Forge('API_TOKEN');
2
3await forge.database.delete(server_id, database_id);

Edit this page on GitHub