Join the Stack Overflow Community
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

I have a collection named "tasks".

var newTask = {
            name: req.body.newTask,
            room: req.body.newRoom,
            users: [req.body.newUser]
        };

I want to insert users in tasks. For example task named "Session" can have multiple users.

{
name: Session,
room: ElementRoom
users: [steve, john]
}

What I'm doing is something like this:-

app.post('/room/task/user', function(req, res, next){
    db.tasks.update(
    { name: req.body.taskName },
    { $push: { users: req.body.username } }
    )
});

But I'm getting this error:- TypeError: Cannot read property 'update' of undefined

what am i doing wrong?

Thanks a lot in advance

share|improve this question
1  
Are you sure you have a collection tasks on the db you have connected !! – Şivā SankĂr 20 hours ago
    
Yes I have a collection named tasks. – Muhammad Hassam 1 hour ago
    
Please post the full code here. What that db variable assigned with ? – Şivā SankĂr 2 mins ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.