W3cubDocs

/RethinkDB JavaScript

ReQL command: indexRename

Command syntax

table.indexRename(oldIndexName, newIndexName[, {overwrite: false}]) → object

Description

Rename an existing secondary index on a table. If the optional argument overwrite is specified as true, a previously existing index with the new name will be deleted and the index will be renamed. If overwrite is false (the default) an error will be raised if the new index name already exists.

The return value on success will be an object of the format {renamed:1}, or {renamed:0} if the old and new names are the same.

An error will be raised if the old index name does not exist, if the new index name is already in use and overwrite is false, or if either the old or new index name are the same as the primary key field name.

Example: Rename an index on the comments table.

r.table('comments').indexRename('postId', 'messageId').run(conn, callback)

Related commands

Get more help

Couldn't find what you were looking for?

© RethinkDB contributors
Licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License.
https://rethinkdb.com/api/javascript/index_rename/