| layout | api-command | ||||||
|---|---|---|---|---|---|---|---|
| language | JavaScript | ||||||
| permalink | api/javascript/db_create/ | ||||||
| command | dbCreate | ||||||
| io |
|
||||||
| related_commands |
|
Command syntax
{% apibody %} r.dbCreate(dbName) → object {% endapibody %}
Description
Create a database. A RethinkDB database is a collection of tables, similar to relational databases.
If successful, the command returns an object with two fields:
dbs_created: always1.config_changes: a list containing one object with two fields,old_valandnew_val:old_val: alwaysnull.new_val: the database's new config value.
If a database with the same name already exists, the command throws ReqlRuntimeError.
Note: Only alphanumeric characters, hyphens and underscores are valid for the database name.
Example: Create a database named 'superheroes'.
> r.dbCreate('superheroes').run(conn, callback); // Result passed to callback { "config_changes": [ { "new_val": { "id": "e4689cfc-e903-4532-a0e6-2d6797a43f07", "name": "superheroes" }, "old_val": null } ], "dbs_created": 1 }