Skip to content

IndexSpec

David Fahlander edited this page Apr 15, 2014 · 12 revisions

Syntax

db.table(tableName).schema.indexes[0]

Properties

name : String

The name of the index. Unless this is a compound index, name will always equal keyPath.

For compound indexes, ´name´ is the String as it was defined in Version.stores() while´keyPath´ is an array of the keyPaths of the compound indexes while.

keyPath : String

Key path of the index. For direct properties, keyPath is the property name. For nestled properties, keyPath will be the path to the nestled key using property names and periods, such as ´"props.shoeSize"´ for an object with structure: { props: { shoeSize: 47 } }

For compound indexes, ´keyPath´ is an array of the keyPaths of the compound indexes while ´name´ is the String as it was defined in Version.stores().

Description

Specification of an index or primary key.

Sample

var db = new Dexie("MyDB");
db.version(1).stores({friends: "++id,name"});

alert ("Primary key: " + db.friends.schema.primKey.keyPath); // Will alert ("id");
Clone this wiki locally