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

@axmit/express-core-mongodb

v1.0.3

Published

A package provide Mongodb module for @axmit/express-core using Mongoose ODM

Readme

Common information

This package provide Mongodb module for @axmit/express-core using Mongoose ODM

Prerequisites

Before using this package you need to authorize yourself into npm registry using npm adduser

Installation

npm i @axmit/express-core-mongodb or yarn add @axmit/express-core-mongodb

Usage

import { ExpressApplication } from '@axmit/express-core';
import { MongodbModule } from '@axmit/express-core-mongodb';

class YourApp extends ExpressApplication {
    public async start() {
      await this.addModule(new MongodbModule());
    }
}

You must also specify MONGO_DB_URL variable in your .env file.

Gulp Mongoose Seed

This package also provide gulp CLI command to seed you DB, you can add it in your gulp file like that:

require('@axmit/express-core-mongodb/gulp');

Use gulp mongoose-seed to load you MongoDB seeders from seeders folder
See MongooseSeeder section for more info

Included Modules

MongooseModelBuilder

Builder for mongoose models, which provides amount of methods to create your model and contain following methods:

constructor(modelName: string) : MongooseModelBuilder

Creates builder instance using provided model name

.useFields(fields): MongooseModelBuilder

Adds model schema by fields param containing classic object defining mongoose schema

.addIndex(fields: any, options?: any): MongooseModelBuilder

Adds mongoose model index on specified fields params, and also you can provide additional mongoose index options

.addSchemaOptions(schemaOptions): MongooseModelBuilder

Adds Mongoose schema options

.addMethod(name: string, method: (...args: any[]) => any): MongooseModelBuilder

Adds mongoose method to model instance
Params:

  • name {String} - method name
  • method {Function} - model instance method (where this is mongoose instance model)

.addStatic(name: string, method: (this: Model, ...arg: any[]) => any): MongooseModelBuilder

Adds mongoose method to model instance
Params:

  • name {String} - method name
  • method {Function} - model instance method (where this is mongoose instance model)

.buildSchema()

Builds only mongoose Schema and returns it

.build()

Build schema and model and return mongoose model class

Usage:

import { MongooseModelBuilder } from '@axmit/express-core-mongodb';  
  
const AmazingModel = new MongooseModelBuilder('ModelName') 
  .useFields({  name: { required: true, type: String },  
    description: { required: true, type: String }  
  }) 
  .build();  

await new AmazingModel({ name: 'test', description: 'test' }).save();  

Note: if you want TypeScript to correct handle your custom methods and statics, you must specify interfaces and pass it into builder generic params as follows:

import { MongooseDocument, MongooseModel, MongooseModelBuilder } from '@axmit/express-core-mongodb';  
  
interface IAmazingDocumentFields extends MongooseDocument {  
  name: string;  
  description: string;  
}  
  
interface IAmazingDocument extends IAmazingDocumentFields {  
  printName(): void;  
}  
  
interface IAmazingModel extends MongooseModel<IAmazingDocument> {  
  printAllRecords(): void;  
}  
  
const AmazingModel = new MongooseModelBuilder<IAmazingDocument, IAmazingModel>('ModelName') 
    .useFields({  name: { required: true, type: String },  
        description: { required: true, type: String }  
    }) 
    .addMethod('printName', function() { 
        console.log(this.name);  
    }) 
    .addStatic('printAllRecords', async function() { 
        const records = await this.find({});  
        console.log(records);  
    }) 
    .build();

Now you can use your static and method as usual

await AmazingModel.printAllRecords(); //prints all records in the collection  
const amazingInstance = await new AmazingModel({ name: 'test', description: 'test1' }).save();  
amazingInstance.printName(); //prints test  

clearMongoDB

This helper cleans up all you collections
Usage:

import { clearMongoDB } from '@axmit/express-core-mongodb';  
  
await clearMongoDB();  

MongooseSeeder

This abstract class helps you to implement mongoose seeders, you need
to create seeders folder in your application root and make it return set of
seeders classes like this

import { MongooseSeeder } from '@axmit/express-core-mongodb';  
  
export class TestSeeder extends MongooseSeeder {  
 public async shouldRun() {  
    return true; 
 }  
 public async run() {  
    //Fill your model here and return amount of created documents 
 }
}  

Note: you must create index file in seeders dir which will export all seeders