При попытке .update()
или .save()
строки я получаю эту ошибку:
Unhandled rejection Error: You attempted to save an instance with no primary key,
this is not allowed since it would result in a global update
Я испробовал все 4 способа, которыми документы используются в качестве примеров (с определением атрибутов и без них, я хочусохранить), ничего не получалось.Это мой актуальный код для обновления:
Sydney.databases.guilds.findOrCreate({
attributes: ['guildLocale'],
where: {
guildID: _guild.id,
},
defaults: {
guildID: _guild.id,
guildLocale: 'en_US',
guildPrefix: '?',
},
}).spread((guild, created) => {
guild.update({guildLocale: args[1]})
.then(() => console.log(7))
.catch((e) => throw e);
});
А это модель гильдии:
let model = sequelize.define('guild', {
guildID: {
field: 'guild_id',
type: DataTypes.STRING,
primaryKey: true,
},
guildLocale: {
field: 'guild_locale',
type: DataTypes.STRING,
},
guildPrefix: {
field: 'guild_prefix',
type: DataTypes.STRING,
},
}, {tableName: 'guilds'});
Что мне здесь не хватает?