{"id":44100,"library":"veden-mongodb","title":"veden-mongodb","description":"A lightweight MongoDB client wrapper for Node.js that simplifies CRUD operations, aggregation, and transaction management. Current version is 1.4.0, with irregular release cadence. It provides a promise-based API with methods like find, insert, update, delete, aggregate, and transaction support. Unlike native MongoDB driver, it reduces boilerplate by accepting a parameter object for database, collection, limits, and field projection. It also includes a startTransaction helper that handles retries and commit/abort logic.","status":"active","version":"1.4.0","language":"javascript","source_language":"en","source_url":null,"tags":["javascript"],"install":[{"cmd":"npm install veden-mongodb","lang":"bash","label":"npm"},{"cmd":"yarn add veden-mongodb","lang":"bash","label":"yarn"},{"cmd":"pnpm add veden-mongodb","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core MongoDB Node.js driver used for all database operations","package":"mongodb","optional":false}],"imports":[{"note":"Package uses CommonJS only; ES module import is not supported.","wrong":"import { MongoDatabase } from 'veden-mongodb'","symbol":"MongoDatabase","correct":"const { MongoDatabase } = require('veden-mongodb')"},{"note":"Package exports an object with MongoDatabase property, not a default export.","wrong":"const MongoDatabase = require('veden-mongodb')","symbol":"MongoDatabase (default import)","correct":"const MongoDatabase = require('veden-mongodb').MongoDatabase"},{"note":"Types are not published; use any or define custom types.","wrong":"import { MongoDatabase } from 'veden-mongodb'","symbol":"TypeScript types","correct":"import type { MongoDatabase } from 'veden-mongodb'"}],"quickstart":{"code":"const { MongoDatabase } = require('veden-mongodb');\n\nconst db = new MongoDatabase({\n  DB_HOSTS: 'localhost',\n  DB_REPLICA_SET: 'test',\n  DB_USER: 'admin',\n  DB_PASS: 'secret123'\n});\n\nconst params = {\n  database: 'users',\n  collection: 'user',\n  limit: 10,\n  fields: ['username', 'email'],\n  exclude_fields: ['_id'],\n  sort: { field: '_id', order: 'asc' }\n};\n\ndb.find(params, { email: /@gmail\\.com$/ }).then(result => {\n  console.log(result);\n}).catch(err => {\n  console.error(err);\n});","lang":"javascript","description":"Connects to a MongoDB instance and performs a find operation with field selection, exclusion, sort, and limit."},"warnings":[{"fix":"Update transaction callbacks to return a promise with the desired result.","message":"In version 1.3.0, the transaction callback signature changed: previously passed (err, result) but now expects async/await returning result.","severity":"breaking","affected_versions":">=1.3.0"},{"fix":"Ensure DB_HOSTS contains a single host:port; if using replica sets, specify the set in DB_REPLICA_SET.","message":"The DB_HOSTS option currently supports a single host only; multi-host replica set strings are not parsed correctly. This behavior may change in future versions.","severity":"deprecated","affected_versions":"<1.5.0"},{"fix":"Use db.count() to check if documents exist before fetching.","message":"The find method returns an empty array when no documents match, but count returns 0. Ensure you check lengths/emptyness appropriately.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use either fields (inclusive) or exclude_fields (exclusive), not both.","message":"The `exclude_fields` parameter overrides `fields` if both are specified. Only one should be used to avoid unexpected results.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Access the _id via result._id instead of the direct return value.","message":"In version 1.4.0, the insertOne return changed: previously returned the inserted document's _id, now returns an object with _id and result properties.","severity":"breaking","affected_versions":">=1.4.0"}],"env_vars":null,"search_vec":"'1.4.0':22 'accept':53 'aggreg':15,41 'also':65 'api':33 'base':32 'boilerpl':51 'cadenc':26 'client':7 'collect':59 'commit/abort':74 'crud':13 'current':19 'databas':58 'delet':40 'driver':48 'field':62 'find':37 'handl':71 'helper':69 'includ':66 'insert':38 'irregular':24 'javascript':76 'lightweight':5 'like':36 'limit':60 'logic':75 'manag':18 'method':35 'mongodb':3,6,47 'nativ':46 'node.js':10 'object':56 'oper':14 'paramet':55 'project':63 'promis':31 'promise-bas':30 'provid':28 'reduc':50 'releas':25 'retri':72 'simplifi':12 'starttransact':68 'support':44 'transact':17,43 'unlik':45 'updat':39 'veden':2 'veden-mongodb':1 'version':20 'wrapper':8","created_at":"2026-06-05T17:02:58.790021+00:00","updated_at":"2026-06-05T17:02:58.790021+00:00","problems":[{"fix":"Use const { MongoDatabase } = require('veden-mongodb');","cause":"Importing incorrectly: using default import instead of destructuring.","error":"TypeError: MongoDatabase is not a constructor"},{"fix":"Run `npm install veden-mongodb` and ensure the package name is spelled correctly.","cause":"Package not installed or typo in package name.","error":"TypeError: Cannot destructure property 'MongoDatabase' of 'require(...)' as it is undefined."},{"fix":"Ensure credentials are correct and add DB_AUTH_SOURCE if using a non-admin auth database.","cause":"Wrong DB_USER or DB_PASS in MongoDatabase constructor, or no authentication database specified.","error":"MongoError: Authentication failed."}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":null,"github":null,"docs":null,"changelog":null,"pypi":null,"npm":"veden-mongodb","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}