I'm attempting to manually delete a document from the connect-mongo sessions collection. When I try to delete a document I get the following error:
message: 'Cast to ObjectId failed for value "gl9-V-bjAjqv2Nwdf9vHPLN_Fnnl4Thz" at path "_id"'
express-session uses the following function to generate a session id:
function generateSessionId(sess) {
return uid(24);
}
The session generated from this function is making it way into the _id property of the sessions document. However when you try and find or delete the document by the generated id you get the error.
The mongodb docs say the _id should be
ObjectId is a 12-byte BSON type ObjectId
I've tried to override the session id using the genid option on the session, but the override doesn't make it into the database.
How can I get a valid _id onto the document or query the document with an invalid _id?
Thanks!
My Infrastructure: Express 4.10, Node v0.12.7, Compose.io, connect-mongo, express-session