Commit 7b6edba2 authored by Chunchi Che's avatar Chunchi Che

update sqlite middleware

parent c37bc844
Pipeline #19734 passed with stages
in 5 minutes and 38 seconds
......@@ -5,7 +5,7 @@ export interface CardMeta {
data: {
ot?: number;
setcode?: number;
type_?: number;
type?: number;
atk?: number;
def?: number;
level?: number;
......
......@@ -6,6 +6,7 @@
* */
import initSqlJs, { Database } from "sql.js";
import { CardMeta } from "../api/cards";
export enum sqliteCmd {
// 初始化
......@@ -44,8 +45,14 @@ export default async function (action: sqliteAction) {
break;
}
case sqliteCmd.SELECT: {
if (YGODB) {
// TDOO
if (YGODB && action.payload) {
const code = action.payload;
const dataStmt = YGODB.prepare("SELECT * from datas WHERE ID = $id");
const dataResult = dataStmt.getAsObject({ $id: code });
const textStmt = YGODB.prepare("SELECT * from texts WHERE ID = $id");
const textResult = textStmt.getAsObject({ $id: code });
return constructCardMeta(code, dataResult, textResult);
} else {
console.warn("ygo db not init!");
}
......@@ -59,3 +66,15 @@ export default async function (action: sqliteAction) {
}
}
}
function constructCardMeta(
id: number,
data: initSqlJs.ParamsObject,
text: initSqlJs.ParamsObject
): CardMeta {
return {
id,
data,
text,
};
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment