Javascript 如何从Dexiejs indexedDB表中获取单列数据
如何仅从每行获取价格Javascript 如何从Dexiejs indexedDB表中获取单列数据,javascript,arrays,dexie,dexiejs,Javascript,Arrays,Dexie,Dexiejs,如何仅从每行获取价格 db - [{ "id": 1, "name": "name 2", "price": 40, "img": "img.jpeg", "isActive": true }, { "id": 2,
db -
[{
"id": 1,
"name": "name 2",
"price": 40,
"img": "img.jpeg",
"isActive": true
}, {
"id": 2,
"name": "name 2",
"price": 60,
"img": "img.jpeg",
"isActive": true
}]
目前,在db.product.toArray()的帮助下,我能够获取所有数据
但是我想从Dexiejs indexedDB获得[40,60]。如果你索引
价格
,你可以使用
const db = new Dexie('yourDBName');
db.version(2).stores({
product: 'id, price'
});
const prices = await db.product.orderBy('price').keys();