作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
const gamem = await gamemodes.findAll({attributes: ['name']});
const newme = await gamemodes.findAll({attributes: ['name']}, {raw: true });
console.log(newme)
const mapi = gamem.map(g => g.name).join('\n') || "No Gamemodes yet!";
await message.channel.send(`Okay! First, choose the gamemode you'd like to search in. List of gamemodes: **${mapi}**. You have 15 seconds, just post your choice here.`)
const msggg = await message.channel.awaitMessages(msg => msg.content == newme.some(), {time: 15000, max: 1});
newme
是这样的:
[ gamemodes {
dataValues: { name: 'Normal' },
_previousDataValues: { name: 'Normal' },
_changed: {},
_modelOptions:
{ timestamps: true,
validate: {},
freezeTableName: false,
underscored: false,
underscoredAll: false,
paranoid: false,
rejectOnEmpty: false,
whereCollection: null,
schema: null,
schemaDelimiter: '',
defaultScope: {},
scopes: [],
indexes: [],
name: [Object],
omitNull: false,
sequelize: [Object],
hooks: {},
uniqueKeys: [Object] },
_options:
{ isNewRecord: false,
_schema: null,
_schemaDelimiter: '',
raw: true,
attributes: [Array] },
__eagerlyLoadedAssociations: [],
isNewRecord: false },
Invalid value Collection {}
at Object.escape (D:\BasementMonster\node_modules\sequelize\lib\sql-string.js:66:11)
at Object.escape (D:\BasementMonster\node_modules\sequelize\lib\dialects\abstract\query-generator.js:934:22)
at Object.whereItemQuery (D:\BasementMonster\node_modules\sequelize\lib\dialects\abstract\query-generator.js:2141:41)
at Utils.getComplexKeys.forEach.prop (D:\BasementMonster\node_modules\sequelize\lib\dialects\abstract\query-generator.js:1994:25)
at Array.forEach (<anonymous>)
at Object.whereItemsQuery (D:\BasementMonster\node_modules\sequelize\lib\dialects\abstract\query-generator.js:1992:35)
at Object.getWhereConditions (D:\BasementMonster\node_modules\sequelize\lib\dialects\abstract\query-generator.js:2460:19)
at Object.selectQuery (D:\BasementMonster\node_modules\sequelize\lib\dialects\abstract\query-generator.js:1140:28)
at QueryInterface.select (D:\BasementMonster\node_modules\sequelize\lib\query-interface.js:1105:27)
at Promise.try.then.then.then (D:\BasementMonster\node_modules\sequelize\lib\model.js:1604:34)
at tryCatcher (D:\BasementMonster\node_modules\bluebird\js\release\util.js:16:23)
at Promise._settlePromiseFromHandler (D:\BasementMonster\node_modules\bluebird\js\release\promise.js:512:31)
at Promise._settlePromise (D:\BasementMonster\node_modules\bluebird\js\release\promise.js:569:18)
at Promise._settlePromise0 (D:\BasementMonster\node_modules\bluebird\js\release\promise.js:614:10)
at Promise._settlePromises (D:\BasementMonster\node_modules\bluebird\js\release\promise.js:693:18)
at Async._drainQueue (D:\BasementMonster\node_modules\bluebird\js\release\async.js:133:16)
at Async._drainQueues (D:\BasementMonster\node_modules\bluebird\js\release\async.js:143:10)
at Immediate.Async.drainQueues (D:\BasementMonster\node_modules\bluebird\js\release\async.js:17:14)
at runCallback (timers.js:794:20)
at tryOnImmediate (timers.js:752:5)
at processImmediate [as _immediateCallback] (timers.js:729:5)
(node:11156) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:11156) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
最佳答案
您需要使用 .toJSON()
将实例更改为 json 对象
const newme = await gamemodes.findAll({attributes: ['name']}, {raw: true })
const array = []
newme.map((data) => {
array.push(data.toJSON())
})
array
了。
关于sequelize.js - Sequelize 和 discord.js - 如何将 sequelize 信息转换为简单数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50446906/
我是一名优秀的程序员,十分优秀!