Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
@nestlab/mongo
Advanced tools
Readme
$ npm i @nestlab/mongo mongodb
$ npm i -D @types/mongodb
Configuration for main module
import { MongoModule } from './mongo.module';
MongoModule.forRoot(
[ // Connections
{
name: 'PRIMARY',
uri: 'mongodb://localhost:27017/primary-database',
reconnectionTimeout: 2000,
},
{
name: 'SECONDARY',
uri: 'mongodb://localhost:27017/secondary-database',
reconnectionTimeout: 2000,
},
],
[Entity1, Entity2], // Entities
);
Configuration for feature module
import { MongoModule } from './mongo.module';
MongoModule.forFeature([ // Entities
Entity3,
Entity4,
]);
Entity declaration
@Entity('cars') // Collection name
export class Car {
name: string;
}
Inject connections
export class CarController {
constructor(@InjectConnection('PRIMARY') primaryConnection: MongoConnection,
@InjectConnection('SECONDARY') secondaryConnection: MongoConnection) {
}
}
Inject repository
export class CarController {
constructor(@InjectRepository(Car) carRepositry: Repository<Car>,
@InjectRepository(Entity) entityRepository: Repository<Entity>) {
}
}
@EntityRepository(Car)
export class CarRepository extends Repository<Car> {
// Your implementation...
}
Injection the same as in default repositories.
Enjoy!
FAQs
Mongo DB module for NestJS
The npm package @nestlab/mongo receives a total of 19 weekly downloads. As such, @nestlab/mongo popularity was classified as not popular.
We found that @nestlab/mongo demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.