Я могу создать таблицу, используя верстак, но не через sequelize ниже мой код, я хочу помочь здесь, я новичок в узле, а также в sequlize. Я просто изучаю документацию и обучающее видео, и оно работает для них, но не для меня: база данных. js
`const Sequelize = require ('sequelize');
const sequelize = new Sequelize('social', 'root', 'root', {
dialect: 'mysql',
host: 'localhost'
});
module.exports = sequelize;
`
for sync
sequelize
.sync({ force: true })
.then(result => {
// console.log(result);
app.listen(PORT, () => console.log(`Server started on port ${PORT}`));
})
.catch(err => {
console.log(err);
});
для модели продукта. js
const Sequelize = require('sequelize');
const sequelize = require('../util/database');
const Product = sequelize.define('product', {
id: {
type: Sequelize.INTEGER,
autoIncrement: true,
allowNull: false,
primaryKey: true
},
title: Sequelize.STRING,
price: {
type: Sequelize.DOUBLE,
allowNull: false
},
imageUrl: {
type: Sequelize.STRING,
allowNull: false
},
description: {
type: Sequelize.STRING,
allowNull: false
}
});
module.exports = Product;
войти в систему syn c
Sequelize {
options: {
dialect: 'mysql',
dialectModule: null,
dialectModulePath: null,
host: 'localhost',
protocol: 'tcp',
define: {},
query: {},
sync: {},
timezone: '+00:00',
clientMinMessages: 'warning',
standardConformingStrings: true,
logging: [Function: bound consoleCall],
omitNull: false,
native: false,
replication: false,
ssl: undefined,
pool: {},
quoteIdentifiers: true,
hooks: {},
retry: { max: 5, match: [Array] },
transactionType: 'DEFERRED',
isolationLevel: null,
databaseVersion: '8.0.19',
typeValidation: false,
benchmark: false,
minifyAliases: false,
logQueryParameters: false
},
config: {
database: 'social',
username: 'root',
password: 'root',
host: 'localhost',
port: 3306,
pool: {},
protocol: 'tcp',
native: false,
ssl: undefined,
replication: false,
dialectModule: null,
dialectModulePath: null,
keepDefaultTimezone: undefined,
dialectOptions: undefined
},
dialect: MysqlDialect {
sequelize: [Circular],
connectionManager: ConnectionManager {
sequelize: [Circular],
config: [Object],
dialect: [Circular],
versionPromise: null,
dialectName: 'mysql',
pool: [Pool],
lib: [Object]
},
QueryGenerator: MySQLQueryGenerator {
sequelize: [Circular],
options: [Object],
dialect: 'mysql',
_dialect: [Circular],
OperatorMap: [Object],
typeValidation: undefined
}
},
queryInterface: QueryInterface {
sequelize: [Circular],
QueryGenerator: MySQLQueryGenerator {
sequelize: [Circular],
options: [Object],
dialect: 'mysql',
_dialect: [MysqlDialect],
OperatorMap: [Object],
typeValidation: undefined
}
},
models: {},
modelManager: ModelManager { models: [], sequelize: [Circular] },
connectionManager: ConnectionManager {
sequelize: [Circular],
config: {
database: 'social',
username: 'root',
password: 'root',
host: 'localhost',
port: 3306,
pool: [Object],
protocol: 'tcp',
native: false,
ssl: undefined,
replication: false,
dialectModule: null,
dialectModulePath: null,
keepDefaultTimezone: undefined,
dialectOptions: undefined
},
dialect: MysqlDialect {
sequelize: [Circular],
connectionManager: [Circular],
QueryGenerator: [MySQLQueryGenerator]
},
versionPromise: null,
dialectName: 'mysql',
pool: Pool {
_factory: [Object],
_count: 1,
_draining: false,
_pendingAcquires: [],
_inUseObjects: [],
_availableObjects: [Array],
_removeIdleTimer: Timeout {
_idleTimeout: 1000,
_idlePrev: [TimersList],
_idleNext: [TimersList],
_idleStart: 552,
_onTimeout: [Function],
_timerArgs: undefined,
_repeat: null,
_destroyed: false,
[Symbol(refed)]: true,
[Symbol(asyncId)]: 57,
[Symbol(triggerId)]: 56
},
_removeIdleScheduled: true
},
lib: {
createConnection: [Function],
connect: [Function],
Connection: [Function: Connection],
createPool: [Function],
createPoolCluster: [Function],
createQuery: [Function: createQuery],
Pool: [Function: Pool],
createServer: [Function],
PoolConnection: [Function],
escape: [Function: escape],
escapeId: [Function: escapeId],
format: [Function: format],
raw: [Function: raw],
createConnectionPromise: [Getter],
createPoolPromise: [Getter],
createPoolClusterPromise: [Getter],
Types: [Getter],
Charsets: [Getter],
CharsetToEncoding: [Getter],
setMaxParserCache: [Function],
clearParserCache: [Function]
}
},
importCache: {}
}
Server started on port 5000