Hello. I am switching from Prisma to Sequelize v7 because Prisma does not support in-memory databases, which are useful in testing. I have defined Sequelize client and some models.
database/sequelize.ts:
import { Sequelize } from "@sequelize/core";
import { PostgresDialect } from "@sequelize/postgres";
import { Item, Listing, Terms, User } from "../models";
const sequelize = new Sequelize({
dialect: PostgresDialect,
database: "realestateexpress",
user: "postgres",
password: "root",
host: "localhost",
port: 5432,
ssl: true,
clientMinMessages: "notice",
models: [Item, Listing, Terms, User]
});
export default sequelize;
models/item.model.ts:
import { CreationOptional, DataTypes, InferAttributes, InferCreationAttributes, Model, NonAttribute } from "@sequelize/core";
import { Attribute, NotNull, Unique, Table, BelongsToMany } from "@sequelize/core/decorators-legacy";
import { Listing } from ".";
@Table({ timestamps: false })
class Item extends Model<InferAttributes<Item>, InferCreationAttributes<Item>> {
declare id: CreationOptional<number>;
@Attribute(DataTypes.STRING)
@Unique
@NotNull
declare name: string;
@BelongsToMany(() => Listing, { through: "ListingItem" })
declare listings?: NonAttribute<Listing[]>;
public toString(): string {
return this.name;
}
}
export default Item;
I entered npx seqeulize-cli migration:generate in terminal and pressed enter, but the sequelize package cannot be resolved.
PS D:\Documents\_Dokumenti\Projekti\_Master\Real Estate App\Node\secure\realestate> npx sequelize-cli migration:generate
Unable to resolve sequelize package in D:\Documents\_Dokumenti\Projekti\_Master\Real Estate App\Node\secure\realestate
Yet the packages are literally installed packages.json:
{
// ...
"dependencies": {
"@sequelize/core": "^7.0.0-alpha.42",
"@sequelize/postgres": "^7.0.0-alpha.48",
// ...
},
"devDependencies": {
"sequelize-cli": "^6.6.5",
// ...
}
}
Hello. I am switching from Prisma to Sequelize v7 because Prisma does not support in-memory databases, which are useful in testing. I have defined Sequelize client and some models.
database/sequelize.ts:models/item.model.ts:I entered
npx seqeulize-cli migration:generatein terminal and pressed enter, but thesequelizepackage cannot be resolved.Yet the packages are literally installed
packages.json:{ // ... "dependencies": { "@sequelize/core": "^7.0.0-alpha.42", "@sequelize/postgres": "^7.0.0-alpha.48", // ... }, "devDependencies": { "sequelize-cli": "^6.6.5", // ... } }