Skip to content

Commit

Permalink
Update index.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
slideslide committed Dec 9, 2023
1 parent 7adacf9 commit 8ac230e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/sqlite/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,13 @@ export async function checkStore() {
try {
const result = await select(sql);
if (result.length > 0) {
console.log(`Table ${storeName} has created.`)
return true; // 表已存在
} else {
// 表不存在,试图创建它
const sql = `CREATE TABLE ${storeName} (key PRIMARY KEY, value);`;
const createAction = await execute(sql);
console.log(`Table ${storeName} now created.`)
return createAction !== undefined && createAction !== false; // 如果 createAction 非 undefined 且非 false,意味着创建成功
}
} catch (err) {
Expand Down Expand Up @@ -449,7 +451,7 @@ export function keys(callback) {
})
.then(result => {
if (result.length > 0) {
return result.map(item => item.id);
return result.map(item => item.key);
} else {
return [];
}
Expand Down

0 comments on commit 8ac230e

Please sign in to comment.