I have gotten this error after running connect()
from dbHandler.tsx
. I suppose this github issue post should help me in this but I am confused in what they are writing. This may be the same error as my last question.
Error Message:
No metadata for "Exercise" was found.at http://127.0.0.1:19000/node_modules/expo/AppEntry.bundle?platform=android&dev=true&hot=false&strict=false&minify=false:170802:321 in _createSuperInternalat node_modules/typeorm/browser/error/TypeORMError.js:6:8 in constructorat http://127.0.0.1:19000/node_modules/expo/AppEntry.bundle?platform=android&dev=true&hot=false&strict=false&minify=false:171687:321 in _createSuperInternalat node_modules/typeorm/browser/error/EntityMetadataNotFoundError.js:6:8 in constructorat node_modules/typeorm/browser/data-source/DataSource.js:283:18 in getMetadataat node_modules/typeorm/browser/repository/Repository.js:20:15 in get__metadataat node_modules/typeorm/browser/repository/Repository.js:29:47 in createQueryBuilder
dbhandler.tsx
import { DataSource } from "typeorm";import { Exercise } from "./entities/Exercise";async function connect() {await AppDataSource.initialize() .then(() =>{ console.log("Data Source has been initialized"); asyncDBTest(); }) .catch(() => console.error("Error during data source init."));}const AppDataSource = new DataSource({ type: "expo", database: "GymTracker", driver: require("expo-sqlite"), entities: ["entities/*.{tsx,js}"], migrations: ["migrations/reloadData.sql"]});async function asyncDBTest() { console.log("entered asynDBTest"); await AppDataSource.runMigrations().then(() => extractText() ).catch((err)=>console.log(err));}async function extractText() { console.log("entered extractText"); const exercise = await AppDataSource .getRepository(Exercise) .createQueryBuilder("exercise") .where("exercise.id = :id", { id: 1 }) .getOne() .then(() => console.log(exercise.name) );}export { AppDataSource, asyncDBTest, connect };
entities/Exercise.tsx
import {Entity,Column, PrimaryGeneratedColumn} from "typeorm/browser";@Entity("Exercise")export class Exercise{ @PrimaryGeneratedColumn() id!:number; @Column("text") name!: Text; @Column("text") notes:Text; @Column('text') imageJSON:Text;}