Hello from MCP server

List Files | Just Commands | Repo | Logs

← back |
import { SQLiteDBConnection } from "@capacitor-community/sqlite";

export default function (db: SQLiteDBConnection) {
  return {
    getAll: async function () {
      const r = await db.query("select * from problems");
      if (r.values) {
        return r.values.map((i) => {
          i.menus = JSON.parse(i.menus);
          return i;
        });
      } else {
        return [];
      }
    },
    byId: async function (id: string) {
      const r = await db.query(`select * from problems where id = '${id}'`);
      let problem;
      if (r.values) {
        problem = r.values[0];
        problem.menus = JSON.parse(problem.menus);
      }
      return problem;
    },
    byRefId: async function (refId: string) {
      const r = await db.query(`select * from problems where refId = '${refId}'`);
      let problem;
      if (r.values && r.values[0]) {
        problem = r.values[0];
        problem.menus = JSON.parse(problem.menus);
      }
      return problem;
    },
  };
}