Git Product home page Git Product logo

Comments (9)

arthurgrevin avatar arthurgrevin commented on May 22, 2024 1

Hundredth start is for me :)

from typeorm.

pleerock avatar pleerock commented on May 22, 2024

please install latest version of node

from typeorm.

arthurgrevin avatar arthurgrevin commented on May 22, 2024

I upgrade to v7.0.0 but I get a new error :

/node_modules/typeorm/metadata/types/ColumnTypes.js:64
return type.name.toLowerCase();
^

TypeError: Cannot read property 'name' of undefined
at Function.typeToString (/home/grevin/nba_prono/node_modules/typeorm/metadata/types/ColumnTypes.js:64:20)
at /home/grevin/nba_prono/node_modules/typeorm/decorator/columns/PrimaryGeneratedColumn.js:13:57
at DecoratePropertyWithoutDescriptor (/home/grevin/nba_prono/node_modules/reflect-metadata/Reflect.js:555:13)
at Object.decorate (/home/grevin/nba_prono/node_modules/reflect-metadata/Reflect.js:108:20)
at __decorate (/home/grevin/nba_prono/models/Match.js:4:92)
at /home/grevin/nba_prono/models/Match.js:12:5
at Object. (/home/grevin/nba_prono/models/Match.js:31:2)
at Module._compile (module.js:573:32)
at Object.Module._extensions..js (module.js:582:10)
at Module.load (module.js:490:32)

The file that seemed to cause an issue :


import {ITeam} from "./Team";
import {Table,Column,PrimaryGeneratedColumn} from "typeorm";



@Table()
export class Match {

    @PrimaryGeneratedColumn()
    id:number;

    @Column()
    home: string;

    @Column()
    away: string;

    @Column()
    winner: string;


    @Column()
    date: Date;

}

from typeorm.

pleerock avatar pleerock commented on May 22, 2024

can you provide sources for other files too? did you add import "reflect-metadata"; in your app's main file?

from typeorm.

arthurgrevin avatar arthurgrevin commented on May 22, 2024
import * as http from "http";
import express = require("express");
import {teamMap} from "./models/Team";
import  "reflect-metadata";
import {createConnection} from "typeorm";
import {Match} from "./models/Match";


const hello : string = "Hello";

const app: express.Application = express();

createConnection({
    driver: {
        type: "sqlite",
        database: "nba_prono"
    },
    entities: [
        Match
    ],
    autoSchemaSync: true,
}).then(connection => {

    const celtics = teamMap['Celtics'];
    const warriors = teamMap['Warriors'];
    let match = new Match();
    match.away =  celtics.name;
    match.home = warriors.name;
    match.winner = warriors.name;
    match.date = new Date();

    let matchRepository = connection.getRepository (Match);
    matchRepository.persist(match);

    // here you can start to work with your entities
});


app.get("/api/v1/teams", (request: express.Request, response: express.Response) => {
    response.json(teamMap);
});

app.get("/api/v1/teams/:name",(request:express.Request, response: express.Response)=>{
    const name = request.params('name');
    response.json(teamMap[name]);
});



console.log(hello);


const server: http.Server = app.listen(3000);

it's the main file.

from typeorm.

pleerock avatar pleerock commented on May 22, 2024

You also need to set "emitDecoratorMetadata": true in your tsconfig.json file

from typeorm.

arthurgrevin avatar arthurgrevin commented on May 22, 2024

That's was it. Thank you for your help :)

from typeorm.

pleerock avatar pleerock commented on May 22, 2024

don't forget to star the project ;)

from typeorm.

dgreene1 avatar dgreene1 commented on May 22, 2024

My solution was different. I had to point to the post-transplantation files. See here:
#3629 (comment)

from typeorm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.