MongoDB: Alter indexes
This commit is contained in:
parent
91bb94eda6
commit
9edfe6d1ff
|
@ -245,6 +245,7 @@ if (isset($_GET["mongo"])) {
|
||||||
$return[$index["name"]] = array(
|
$return[$index["name"]] = array(
|
||||||
"type" => ($index["name"] == "_id_" ? "PRIMARY" : ($index["unique"] ? "UNIQUE" : "INDEX")),
|
"type" => ($index["name"] == "_id_" ? "PRIMARY" : ($index["unique"] ? "UNIQUE" : "INDEX")),
|
||||||
"columns" => array_keys($index["key"]),
|
"columns" => array_keys($index["key"]),
|
||||||
|
"lengths" => array(),
|
||||||
"descs" => $descs,
|
"descs" => $descs,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -309,6 +310,32 @@ if (isset($_GET["mongo"])) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function alter_indexes($table, $alter) {
|
||||||
|
global $connection;
|
||||||
|
foreach ($alter as $val) {
|
||||||
|
list($type, $name, $set) = $val;
|
||||||
|
if ($set == "DROP") {
|
||||||
|
$return = $connection->_db->command(array("deleteIndexes" => $table, "index" => $name));
|
||||||
|
} else {
|
||||||
|
$columns = array();
|
||||||
|
foreach ($set as $column) {
|
||||||
|
$column = preg_replace('~ DESC$~', '', $column, 1, $count);
|
||||||
|
$columns[$column] = ($count ? -1 : 1);
|
||||||
|
}
|
||||||
|
$return = $connection->_db->selectCollection($table)->ensureIndex($columns, array(
|
||||||
|
"unique" => ($type == "UNIQUE"),
|
||||||
|
"name" => $name,
|
||||||
|
//! "sparse"
|
||||||
|
));
|
||||||
|
}
|
||||||
|
if ($return['errmsg']) {
|
||||||
|
$connection->error = $return['errmsg'];
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
function last_id() {
|
function last_id() {
|
||||||
global $connection;
|
global $connection;
|
||||||
return $connection->last_id;
|
return $connection->last_id;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
Adminer 4.0.3-dev:
|
Adminer 4.0.3-dev:
|
||||||
MongoDB: insert, truncate
|
MongoDB: insert, truncate, indexes
|
||||||
SimpleDB, MongoDB: insert more fields at once
|
SimpleDB, MongoDB: insert more fields at once
|
||||||
|
|
||||||
Adminer 4.0.2 (released 2014-01-11):
|
Adminer 4.0.2 (released 2014-01-11):
|
||||||
|
|
Loading…
Reference in a new issue