{"library":"monk-middleware-cast-ids","title":"monk-middleware-cast-ids","description":"A middleware for the Monk MongoDB library that automatically casts string IDs to MongoDB ObjectId instances. Version 0.2.1 is the latest stable release. This package is specific to Monk's middleware system and is no longer actively maintained; it is superseded by Monk's built-in castIds option. Key differentiator: it allows automatic ID casting in older Monk versions that lack native support.","language":"javascript","status":"deprecated","last_verified":"Sat Apr 25","install":{"commands":["npm install monk-middleware-cast-ids"],"cli":null},"imports":["import castIds from 'monk-middleware-cast-ids'","const castIds = require('monk-middleware-cast-ids').default","import castIds from 'monk-middleware-cast-ids'"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import monk from 'monk';\nimport castIds from 'monk-middleware-cast-ids';\n\nconst db = monk('localhost/myapp', {\n  useUnifiedTopology: true,\n});\nconst collection = db.get('users');\ncollection.addMiddleware(castIds);\n\n// Now string IDs are automatically cast to ObjectId\nconst result = await collection.findOne({ _id: '507f1f77bcf86cd799439011' });\nconsole.log(result);","lang":"typescript","description":"Demonstrates how to add the cast-ids middleware to a Monk collection, enabling automatic string-to-ObjectId conversion.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}