Добрый день. Делаю запрос к базе
User.findAll().then(users => {
console.log(users)
});
через sequelize, получаю простыню в консоли, включая подключение к базе и прочее. Причем без остановки
_evictionIterator:
DequeIterator {
_list:
DoublyLinkedList {
head:
{ prev: null,
next:
{ prev: [Circular],
next: null,
data:
PooledResource {
creationTime: 1541403796957,
lastReturnTime: 1541403796967,
lastBorrowTime: 1541403796962,
lastIdleTime: 1541403796967,
obj:
Client {
domain: null,
_events:
[Object: null prototype] { end: [Function], error: [Function] },
_eventsCount: 2,
_maxListeners: undefined,
connectionParameters:
ConnectionParameters {
user: 'postgres',
и прочее.
Мой код
import { Sequelize } from 'sequelize-typescript';
import * as express from 'express';
import { appconfig } from '../config/appconfig';
import app from "./app";
import {User } from "../modules/user/models/user.model";
const server = express();
// allow access from client server
server.use(function (req, res, next) {
res.setHeader('Access-Control-Allow-Origin', 'http://localhost:3000');
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type');
next();
});
export const sequelize = new Sequelize({
database: appconfig.dbdatabase,
dialect: appconfig.dbdialect,
username: appconfig.dbusername,
password: appconfig.dbpassword,
host: appconfig.dbhost,
port: appconfig.dbport
});
sequelize.authenticate().then(() => {
console.log("Connected to DB");
})
.catch((err) => {
console.log(err);
})
app.listen(appconfig.port, () => {
console.log('Express server listening on port ' + appconfig.port);
})
sequelize.addModels([User]);
User.findAll().then(users => {
console.log(users)
});
Что же там sequelize возвращает? Это потому что без промиса?
Пример запроса брал с
Getting Started