Created
January 17, 2015 06:53
-
-
Save mirhec/6aeca7c922e702e4d77d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### | |
## This creates the given index for the given | |
## table. If there occurs an error | |
## it will be printed out. If it succeeds, the | |
## callback next will be called. | |
### | |
createIndex: (tableName, indexName, next) -> | |
r.table(tableName).indexCreate(indexName).run @conn, (err, result) => | |
if (err) and (not err.message.match(/Index `.*` already exists/)) | |
console.log "Could not create the index `" + tableName + "." + indexName + "`" | |
console.log err | |
process.exit 1 | |
console.log "Index `" + tableName + "." + indexName + "` created." | |
r.table(tableName).indexWait(indexName).run @conn, (err, result) => | |
if err | |
console.log "Could not wait for the completion of the index `" + tableName + "." + indexName + "`" | |
console.log err | |
process.exit 1 | |
console.log "Index `" + tableName + "." + indexName + "` ready." | |
if next? | |
next() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment