npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@vsaas/loopback-connector-mongodb

v11.0.2

Published

Fork of LoopBack MongoDB connector for @vsaas LoopBack projects, providing seamless integration with MongoDB databases

Readme

@vsaas/loopback-connector-mongodb

Maintained MongoDB connector fork for LoopBack 3.

This fork stays focused on practical LB3 compatibility while simplifying the codebase:

  • runtime moved to TypeScript
  • modern build and test tooling (tsdown, vitest, oxlint)
  • English-only messages
  • legacy repo assets removed (intl, docs site, benchmarks, examples, old CI files)
  • MongoDB driver kept on the 5.x line to remain compatible with MongoDB Server 4.2

Install

npm install @vsaas/loopback-connector-mongodb

Why [email protected]

This fork intentionally stays on [email protected].

That keeps the connector on a conservative driver line that still works with MongoDB Server 4.2, while avoiding the larger behavior and runtime changes introduced by newer major driver lines.

LoopBack 3 datasource example

{
  "db": {
    "name": "db",
    "connector": "@vsaas/loopback-connector-mongodb",
    "host": "127.0.0.1",
    "port": 27017,
    "database": "app",
    "user": "app",
    "password": "secret",
    "authSource": "admin"
  }
}

You can also use a full connection string:

{
  "db": {
    "name": "db",
    "connector": "@vsaas/loopback-connector-mongodb",
    "url": "mongodb://app:[email protected]:27017/app?authSource=admin"
  }
}

Supported connector settings

  • allowExtendedOperators
  • authSource
  • collation
  • database
  • disableDefaultSort
  • enableGeoIndexing
  • host
  • lazyConnect
  • password
  • port
  • protocol
  • strictObjectIDCoercion
  • url
  • user

The connector also forwards common MongoDB driver options such as:

  • connectTimeoutMS
  • serverSelectionTimeoutMS
  • socketTimeoutMS
  • readPreference
  • replicaSet
  • retryWrites
  • writeConcern

Notes

  • enableGeoIndexing: true is required for indexed near queries on GeoPoint.
  • Default ids use MongoDB ObjectId.
  • Custom collection names are supported via model settings:
{
  mongodb: {
    collection: 'CustomCollection';
  }
}
  • Custom field names are supported for non-id properties:
{
  title: {
    type: String,
    mongodb: { fieldName: 'custom_title' }
  }
}

LoopBack still must keep the primary key stored as _id; custom field names for the id property are not supported.

ObjectId handling

You can enforce ObjectId coercion in two common ways.

Per model:

{
  options: {
    strictObjectIDCoercion: true;
  }
}

Per property:

{
  id: {
    type: 'String',
    id: true,
    mongodb: { dataType: 'ObjectId' }
  }
}

Update operators

Set allowExtendedOperators: true in the datasource to allow MongoDB update operators like:

  • $set
  • $unset
  • $inc
  • $max
  • $min
  • $mul
  • $rename
  • $push
  • $pull

Example:

Product.updateAll({ category: 'furniture' }, { $max: { price: 100 } }, cb);

Security

The connector removes $where and mapReduce from filters by default before sending them to MongoDB.

If you really need them for trusted internal code, pass:

{
  disableSanitization: true;
}

Development

Local test defaults:

npm test
npm run lint
npm run typecheck

Test connection settings come from:

  • MONGODB_HOST
  • MONGODB_PORT
  • MONGODB_DATABASE

If they are not set, the suite uses localhost:27017.