Mongoose - pushing refs - cannot read property "push" of undefined
The users
object is a Mongoose model and not an instance of it. You need the correct instance of the users
model to add the category to.
dashboard.js
...category_toAdd = { _id: mongoose.Types.ObjectId(), name: req.body.categoryName, ownerId: req.body.ownerId};// Create the category here. `category` is the saved category.category.create(category_toAdd, function (err, category) { if (err) console.log(err); // Find the `user` that owns the category. users.findOne(category.ownerId, function (err, user) { if (err) console.log(err); // Add the category to the user's `categories` array. user.categories.push(category); });});