Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

Typeorm: find() returns undefined results

$
0
0

I am not sure why doesconsole.log(exercise) in my method extractData() returns undefined? I think I have already did the entity classes and migration files.

Snippet of App.tsx

const AppDataSource = new DataSource({  type: "expo",  database: "GymTracker",  driver: require("expo-sqlite"),  entities: [Exercise, MajorMuscles, SetOfSets],  migrations: ['migrations/test.ts'],  synchronize: false,  migrationsRun: true,  logging: true,});AppDataSource.initialize()  .then(() => {    console.log("Data Source has been initialized");    asyncDBTest();  })  .catch((err) => {    console.error(err +"Error during data source init.")  });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 repo = AppDataSource.getRepository(Exercise);  const exercise = await repo.find().then(() => {    console.log(exercise);  });}

Exercise.tsx

import {Entity,Column, PrimaryGeneratedColumn} from "typeorm/browser";import "reflect-metadata";@Entity({name:"exercise"})export class Exercise{    @PrimaryGeneratedColumn("uuid")    id!:number;    @Column("text")    name!: Text;    @Column("text")    notes:Text;    @Column('text')    imageJSON:Text;}

test.tsx, my migration file

import { MigrationInterface, QueryRunner } from "typeorm"export class test1657016189203 implements MigrationInterface {    public async up(queryRunner: QueryRunner): Promise<void> {        ...        await queryRunner.manager.query('INSERT INTO exercise (name) VALUES ("Conventional Deadlift")',);        await queryRunner.manager.query('INSERT INTO exercise (name) VALUES ("Romanian Deadlift")',);        await queryRunner.manager.query('INSERT INTO exercise (name) VALUES ("Straight-legged Deadlift")',);        await queryRunner.manager.query('INSERT INTO exercise (name) VALUES ("Sumo Deadlift")',);        ...    }    public async down(queryRunner: QueryRunner): Promise<void> {    }}

Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>