CreateDatabase
CreateDatabase( param_object )
CreateDatabase( param_object )
CreateDatabase( param_object )
CreateDatabase( param_object )
create_database( param_object )
create_database param_object
CreateDatabase( param_object )
CreateDatabase( param_object )
Description
The CreateDatabase
function adds a new database to the cluster with
the specified parameters. It requires an admin key for authentication.
Parameters
Argument | Type | Definition and Requirements |
---|---|---|
|
Object |
The param_object fields are described below. |
param_object
Field Name | Field Type | Definition and Requirements |
---|---|---|
|
String |
The name of a database. Databases cannot be named any of the following
reserved words: |
|
Object |
Optional - This is user-defined metadata for the database. It is provided for the developer to store information at the database level. |
|
Number |
Optional - The default client driver API version for the requests made to this database. Defaults to "2.0" |
|
Long |
Optional - A relative weight between 1 and 500, inclusive, indicating how many resources this database is allowed to utilize. Defaults to 1. A higher number means more resources. |
Returns
An object containing the metadata of CreateDatabase
operations.
Field Name | Field Type | Definition and Requirements |
---|---|---|
|
Reference |
The reference is an automatically generated unique identifier for the database that was created. |
|
String |
The name of the database just created. |
|
Long |
The timestamp associated with the creation of the document. |
Examples
The query below creates a database named "db-next" and returns the reference to the database, the name of the database, and the time the database was created.
curl https://db.fauna.com/ \
-u fnAChGwBacACAEZtRZFDXpyjIvq-sln34m-va4Km: \
-d '{ "create_database": { "object": { "name": "db-next" } } }'
client.Query(CreateDatabase(Obj("name", "db-next")));
System.out.println(
client.query(
CreateDatabase(Obj("name", Value("db-next")))
).get());
result, _ := client.Query(f.CreateDatabase(f.Obj{"name": "db-next"}))
fmt.Println(result)
client.query(CreateDatabase(Obj("name" -> "db-next")))
client.query(q.create_database({"name": "db-next"}))
$client.query do
create_database name: 'db-next'
end
client.query(CreateDatabase(Obj("name" => "db-next")))
client.query(q.CreateDatabase({ name: "db-next" }))
.then((ret) => console.log(ret))
HTTP/1.1 201 Created
{
"resource": {
"ref": { "@ref": "databases/db-next" },
"class": { "@ref": "databases" },
"ts": 1509244539938619,
"name": "db-next"
}
}
{
"ref": { "@ref": "databases/db-next" },
"class": { "@ref": "databases" },
"ts": 1509244539938619,
"name": "db-next"
}
{
ref: ref(id = "db-next", collection = ref(id = "databases")),
ts: 1526674566784752,
name: "db-next"
}
map[ref:{db-next 0xc42021caa0 <nil>} ts:1509244539938619 name:db-next]
{
"ref": { "@ref": "databases/db-next" },
"class": { "@ref": "databases" },
"ts": 1509244539938619,
"name": "db-next"
}
{
"ref": { "@ref": "databases/db-next" },
"class": { "@ref": "databases" },
"ts": 1509244539938619,
"name": "db-next"
}
{
"ref": { "@ref": "databases/db-next" },
"class": { "@ref": "databases" },
"ts": 1509244539938619,
"name": "db-next"
}
{
"ref": { "@ref": "databases/db-next" },
"class": { "@ref": "databases" },
"ts": 1509244539938619,
"name": "db-next"
}
{ ref: Ref(id=db-next, collection=Ref(id=databases)),
ts: 1527274824500534,
name: 'db-next' }
Was this article helpful?
We're sorry to hear that.
Tell us how we can improve!
documentation@fauna.com
Thank you for your feedback!