我的dexiedb结构如下所示:
const db = new Dexie('shipment-execution');
db.version(1).stores({
root: '++id,shipmentid,stopid',
})
我的IndexedDB将如下所示
| id| shipmentid| stopid|
| 1 | 6000001 | 10 |
| 2 | 6000001 | 20 |
| 3 | 6000001 | 30 |
| 4 | 6000002 | 10 |
| 5 | 6000002 | 20 |
我正试图获得所有已发货的数据等于6000001。每次只返回一条记录(第一条记录)。
db.root.where({shipmentid : '6000001'}).toArray().then((d)=>{
console.log(d);
})
输出只获取第一个记录
| id| shipmentid| stopid|
| 1| 6000001 | 10 |
请告诉我,我做错了什么。
(async()=>{
await db.root.where('shipmentid').equals('6000001').toArray().then((d)=>{
console.log(d);
})
})();
试试这个,记住shipmentid是字符串或数字