Jonathan
Jonathan•2d ago

Setting up Deno 2.0 with Fresh and TypeORM

I am trying to setup my first deno project ever using Fresh and TypeORM. I have setup 2 files A data.ts
import { DataSource } from "npm:typeorm";
import { User } from "../modules/auth/user.model.ts";

const dataSource = new DataSource({
type: "mssql",
url: Deno.env.get("DATABASE_URL"),
entities: [User],
});

export default dataSource;
import { DataSource } from "npm:typeorm";
import { User } from "../modules/auth/user.model.ts";

const dataSource = new DataSource({
type: "mssql",
url: Deno.env.get("DATABASE_URL"),
entities: [User],
});

export default dataSource;
And a user.model.ts
import { Column, Entity, PrimaryColumn } from "npm:typeorm";

@Entity({ name: "User" })
export class User {
@PrimaryColumn()
id: string;

@Column()
email: string;

}
import { Column, Entity, PrimaryColumn } from "npm:typeorm";

@Entity({ name: "User" })
export class User {
@PrimaryColumn()
id: string;

@Column()
email: string;

}
I am getting a few errors in the user.model.ts , I am not sure if I am importing type orm correctly.
Unable to resolve signature of property decorator when called as an expression.
Unable to resolve signature of property decorator when called as an expression.
I am also not sure how to properly install the mssql properly for deno, do I do that in the deno.json? If so how? And last, I am getting an error of an uncaught promise in Reflect.getMetadata. How do I get around this?
3 Replies
Jonathan
Jonathan•2d ago
I updated my data.ts to
import { DataSource } from "npm:typeorm";
import { User } from "../entity/user.model.ts";
import * as mssql from "npm:mssql";
import * as reflectMetadata from "npm:reflect-metadata";
const dataSource = new DataSource({
type: "mssql",
url: Deno.env.get("DATABASE_URL"),
entities: [User],
synchronize: false
});

export default dataSource;
import { DataSource } from "npm:typeorm";
import { User } from "../entity/user.model.ts";
import * as mssql from "npm:mssql";
import * as reflectMetadata from "npm:reflect-metadata";
const dataSource = new DataSource({
type: "mssql",
url: Deno.env.get("DATABASE_URL"),
entities: [User],
synchronize: false
});

export default dataSource;
And now I am getting "No metadata for User was found" yet it is specified
Jonathan
Jonathan•2d ago
It looks like Deno doesn't work with SQL Azure https://github.com/denoland/deno/issues/20594
GitHub
mssql ConnectionError · Issue #20594 · denoland/deno
Hi, I'm trying to run this code with mssql: import sql from "npm:mssql@10.0.1"; const sqlConfig = { server: "localhost", user: "sa", password: "", databa...
Jonathan
Jonathan•2d ago
😦