I'm got an empty array in my model that I am trying to push an array to but Compass does not show any changes to the document.
I've tried setting the type of my user_list
property to array
in my model, as well as just setting it as an empty array with []
. I have also deleted and recreated the entire database as well to make sure it wasn't a memory issue.
Model:
const guildSchema = new Schema({
guild_name: String,
guild_id: { type: String, unique: true },
...
user_list: []
})
Fetching the array and trying to push:
bot.on("guildUpdate", (oldGuild, newGuild) => {
let userList = newGuild.fetchMembers().then(function(results){ console.log(results.members.keyArray()); userList = results.members.keyArray();
Guild.findOneAndUpdate({guild_id: oldGuild.id}, {"$set": {"guild_name": newGuild.name, "guild_icon": newGuild.iconURL}}, {"$push": {"user_list": userList}}, function(err) {
if (err) throw (err);
});
}).catch(console.error)
})
console.log(results.members.keyArray())
returns the simple array that I am trying to push just fine. Compass shows updates made with $set
just fine as well. Something is going wrong when trying to push to user_list
, as Compass continues to just show a blank array upon update.