Using mongoskin.
I’m trying to do a simple update and I keep on getting the error:
Error: Argument passed in must be a single String of 12 bytes or a string of 24 hex characters in hex format
Different code that I have tried:
var mongo = require('mongoskin'),
store = mongo.db(MONGO_DB_ADDESS + ':' + MONGO_DB_PORT + '/' + MONGO_DB_NAME + '?auto_reconnect=false');
session._id = 4eb5444d39e153e60b000001;
store.collection('sessions').updateById({_id : session._id}, {$set: status_obj}, {upsert : false, multi : false, safe : false}, function() { ... });
store.collection('sessions').updateById(session._id, {$set: status_obj} );
Even tried:
store.collection('sessions').update( {'_id': session._id}, {$set: {"status":'unavailable'}} );
Any help appreciated!
Thanks
Fyi, I can do the update via mongo using the cli just fine:
db.sessions.update( {'_id': ObjectId('4eb5444d39e153e60b000001')}, {$set: {"status":'unavailable'}} );
Adding .toString() finally resolved this for me.