检查 WebSQL 中是否存在索引

Check if index exists in WebSQL

有没有办法检查 WebSQL 数据库中 table 的索引是否存在? 我正在使用 CREATE UNIQUE INDEX INDEX_GUID ON TABLE PERSONS 进行创作。但是如果索引已经存在,我会得到一个错误:

{
    code: 5, // SYNTAX_ERR - from docs
    message: "could not prepare statement (1 index INDEX_GUID already exists)"
}

对我来说最好的解决方案是列出 table 的所有索引。

我正在使用它,但这是一种解决方法。我希望错误信息总是英文的。

db.transaction(function (tx) {
    tx.executeSql(
        "CREATE UNIQUE INDEX INDEX_GUID ON TABLE PERSONS",
        [],
        function (tx, rs) {
            // index created
        },
        function (tx, e) {
            if (e.message.indexOf("already exists") == -1) {
                // index not created - already exists
            }
        });
    );
});