Answer the question
In order to leave comments, you need to log in
How to get clean #sequelize data?
I use to work with mysql Sequelize. but when fetching data, it returns its object, like this:
top {
dataValues:
{ id: 4,
is_bool: true,
value: 'some value',
order: 4,
mid: [],
bot: [ [Object], [Object], [Object], [Object] ] },
_previousDataValues:
{ id: 4,
is_bool: true,
value: 'some value',
order: 4,
mid: [],
bot: [ [Object], [Object], [Object], [Object] ] },
_changed: {},
_modelOptions:
{ timestamps: false,
validate: {},
freezeTableName: true,
underscored: true,
underscoredAll: false,
paranoid: false,
rejectOnEmpty: false,
whereCollection: { id: [Array] },
schema: null,
schemaDelimiter: '',
defaultScope: {},
scopes: [],
indexes: [],
name: { plural: 'tops', singular: 'top' },
omitNull: false,
version: false,
sequelize:
Sequelize {
options: [Object],
config: [Object],
dialect: [Object],
queryInterface: [Object],
models: [Object],
modelManager: [Object],
connectionManager: [Object],
importCache: {},
test: [Object] },
hooks: {},
uniqueKeys: {} },
_options:
{ isNewRecord: false,
_schema: null,
_schemaDelimiter: '',
include: [ [Object], [Object] ],
includeNames: [ 'mid', 'bot' ],
includeMap: { mid: [Object], bot: [Object] },
includeValidated: true,
attributes: [ 'id', 'is_bool', 'value', 'order' ],
raw: true },
__eagerlyLoadedAssociations: [],
isNewRecord: false,
mid: [],
bot:
[ fields_item {
dataValues: [Object],
_previousDataValues: [Object],
_changed: {},
_modelOptions: [Object],
_options: [Object],
__eagerlyLoadedAssociations: [],
isNewRecord: false },
fields_item {
dataValues: [Object],
_previousDataValues: [Object],
_changed: {},
_modelOptions: [Object],
_options: [Object],
__eagerlyLoadedAssociations: [],
isNewRecord: false },
fields_item {
dataValues: [Object],
_previousDataValues: [Object],
_changed: {},
_modelOptions: [Object],
_options: [Object],
__eagerlyLoadedAssociations: [],
isNewRecord: false },
fields_item {
dataValues: [Object],
_previousDataValues: [Object],
_changed: {},
_modelOptions: [Object],
_options: [Object],
__eagerlyLoadedAssociations: [],
isNewRecord: false } ] }
Answer the question
In order to leave comments, you need to log in
const model = await Model.findById(...);
const data = model.toJSON();
console.log(data);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question