1

When define a schema with ydn-db I can define a single column as PK with this code:

var products = {
    name: 'products',
    keyPath: 'id_product',
    autoIncrement: true,
    indexes: [
        {keyPath: 'id_product'},
        {keyPath: 'id_supplier'}
    ]
};

var schema = {
    stores: [products]
};

How I can define a Store (table) with one PK with two columns or more? Thanks

Fernando
  • 99
  • 2
  • 9

1 Answers1

1

How I can define a Store (table) with one PK with two columns or more?

I am not sure answering your question. IndexedDB (ynd-db is very IDB centric) can have only one PK. But primary key can be compound key compose of multiple keyPath (column) using array keypath. It is define like this

var products = {
  name: 'products',
  keyPath: ['id_category', id_product']
};
Kyaw Tun
  • 12,447
  • 10
  • 56
  • 83