Opening and index on two fields at once it's not possible however there is a indexed solution for your case.
You need to create a new index for an array field which will contain both teams with multiEntry
property set to true
.
objectStore.createIndex("teams", ["teams"], {unique: false, multiEntry: true});
And then store both teams as array of strings into that field
var obj = {
hometeam: "Russia",
awayteam: "Usa",
teams: ["Russia", "Usa"]
}
Now when you query the database on that field you should get all games in which Russia
is playing:
var index = objectStore.index("teams");
var keyRange = IDBKeyRange.only("Russia");
var cursorRequest = index.openCursor(keyRange);