A
A
Alexander2020-07-16 18:18:31
Node.js
Alexander, 2020-07-16 18:18:31

TypeError: sequelize.import is not a function?

The code:

const Sequelize = require('sequelize');

const sequelize = new Sequelize('database', 'username', 'password', {
    host: 'localhost',
  dialect: 'sqlite',
  logging: false,
  storage: 'database.sqlite',
});

const CurrencyShop = sequelize.import('models/CurrencyShop');
const Users = sequelize.import('models/Users');
const UserItems = sequelize.import('models/UserItems');


Error:

TypeError: sequelize.import is not a function

How to fix?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Michael, 2020-07-16
@Alexandre888

.importhttps : //github.com/sequelize/sequelize/releases/ta
...

R
Roman Andreevich, 2020-07-16
@RomanDillerNsk

xs. as there is not enough input data, read the doc, there is a lot of things written there

A
Andrey Zolotarev, 2020-11-18
@bel_poprygun

Yes, indeed, in the 6th version, .import was removed.
Rewrote it:

let model = sequelize.import(path.join(modelsPath, file))

on this:
let model = require(path.join(modelsPath, file))(sequelize, Sequelize.DataTypes)

Works.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question