1
0
Fork 0

added drop index

This commit is contained in:
Frank Celler 2012-04-20 09:54:26 +02:00
parent db57c967c6
commit 65a6fe3be6
3 changed files with 49 additions and 2 deletions

View File

@ -132,7 +132,7 @@
/// <hr>
///
/// @anchor ShellIndexDbDelete
/// @copydetails JS_RemoveVocbase
/// @copydetails JSF_AvocadoDatabase_prototype__dropIndex
////////////////////////////////////////////////////////////////////////////////
// Local Variables:

View File

@ -4168,7 +4168,7 @@ static v8::Handle<v8::Value> JS_DropVocbaseCol (v8::Arguments const& argv) {
///
/// @FUN{@FA{collection}.dropIndex(@FA{index-handle})}
///
/// Same as above. Instead of a index an index handle can be given.
/// Same as above. Instead of an index an index handle can be given.
///
/// @EXAMPLES
///

View File

@ -290,6 +290,53 @@ AvocadoDatabase.prototype._index = function(id) {
AvocadoEdges.prototype._index = AvocadoDatabase.prototype._index;
////////////////////////////////////////////////////////////////////////////////
/// @brief drops an index
///
/// @FUN{db._dropIndex(@FA{index})}
///
/// Drops the @FA{index}. If the index does not exists, then @LIT{false} is
/// returned. If the index existed and was dropped, then @LIT{true} is
/// returned. Note that you cannot drop the primary index.
///
/// @FUN{db._dropIndex(@FA{index-handle})}
///
/// Drops the index with @FA{index-handle}.
///
/// @EXAMPLES
///
/// @verbinclude shell_index-drop-index-db
////////////////////////////////////////////////////////////////////////////////
AvocadoDatabase.prototype._dropIndex = function(id) {
if (id.hasOwnProperty("id")) {
id = id.id;
}
var re = /^([0-9]+)\/([0-9]+)/;
var pa = re.exec(id);
if (pa == null) {
var err = new AvocadoError();
err.errorNum = internal.errors.ERROR_AVOCADO_INDEX_HANDLE_BAD.code;
err.errorMessage = internal.errors.ERROR_AVOCADO_INDEX_HANDLE_BAD.message;
throw err;
}
var col = this._collection(parseInt(pa[1]));
if (col == null) {
var err = new AvocadoError();
err.errorNum = internal.errors.ERROR_AVOCADO_COLLECTION_NOT_FOUND.code;
err.errorMessage = internal.errors.ERROR_AVOCADO_COLLECTION_NOT_FOUND.message;
throw err;
}
return col.dropIndex(id);
};
AvocadoEdges.prototype._dropIndex = AvocadoDatabase.prototype._dropIndex;
////////////////////////////////////////////////////////////////////////////////
/// @brief prints a database
////////////////////////////////////////////////////////////////////////////////