Check out the docs for node-mongodb findAndModify; the signature looks like:
collection.findAndModify(query, sort, update, options, callback)
So you should do:
posts.findAndModify(
{"title":title, "roster":"yes"},
[['_id','asc']],
{ "$addToSet": { "followers":username } },
{new: true, upsert: true},
function(err, doc){
console.log('find and modified ' +doc);
}
);
The sort
argument is probably optional, but it's unclear so I included it in the example.