Skip to content

No need to do .pull() and .remove() #1

@jtuppy

Description

@jtuppy

function deleteSwap(req, res) {
req.user.swapsForUser.pull(req.params.id);
req.user.swapsForUser.remove();
req.user.save(function (err, user) {

When you call .pull(), you are removing it from the array. If you want to use remove, you'd call it with the id method as well.

See the removing subdocs in mongoose https://mongoosejs.com/docs/subdocs.html#removing-subdocs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions