Skip to content

About

Mongodb helper(s).

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation

chubbyts-mongodb

CI Coverage Status Mutation testing badge npm-version

bugs code_smells coverage duplicated_lines_density ncloc sqale_rating alert_status reliability_rating security_rating sqale_index vulnerabilities

Description

Mongodb helper(s).

Requirements

Installation

Through NPM as @chubbyts/chubbyts-mongodb.

npm i @chubbyts/chubbyts-mongodb@^2.4.1

Usage

upsertIndexes

Creates the given indexes per collection on the default database of the connection string. If an index with the same name already exists with different options, it gets dropped and created again.

import { MongoClient } from 'mongodb';
import { upsertIndexes } from '@chubbyts/chubbyts-mongodb/mongo';

const mongoClient = await MongoClient.connect('mongodb://localhost/app');

await upsertIndexes(mongoClient, {
  pet: [
    {
      key: { id: 1 },
      name: 'pet.id',
      unique: true,
    },
    {
      key: { name: 1 },
      name: 'pet.name',
    },
  ],
});

Copyright

2026 Dominik Zogg

About

Mongodb helper(s).

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages