Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mongtype

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongtype

Mongo Repository for Node written in TypeScript

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
15
decreased by-67.39%
Maintainers
1
Weekly downloads
 
Created
Source

MongType

MongoDB Repository pattern for NodeJS written in TypeScript.

NOTE: THIS PROJECT IS IN THE EARLY PHASES AND NOT READY FOR PROD USE YET..

Install

npm i mongtype --S

Building

npm run build

Usage

Simple
import { MongoRepository, Collection, Pre, Post, Database } from 'mongood';

interface User {
  name: string;
}

@Collection({
  name: 'user'
})
export class UserRepository extends MongoRepository<User> {
  @Before('save')
  doSomethingBeforeSave() {}

  @After('save')
  doSomethingAfterSave() { }
}

// Usage
const db = new Database();
db.connect('uri');
const svc = new UserRepository(db);

// CRUD Examples
const one = await svc.findById('3434-34-34343-3434');
const many = await svc.find({ conditions: { name: 'foo' } });
const newOne = await svc.create({ foo: true });
const updated = await svc.save(newOne);
Example with injection-js
import { ReflectiveInjector, Injectable, Injector } from 'injection-js';

const injector = ReflectiveInjector.resolveAndCreate([
  UserRepository, 
  Database,
  MyClass
]);

@Injectable()
export class MyClass {
  constructor(private svc: UserRepository) { }
}

console.log(injector.get(MyClass) instanceof MyClass);

Similar

  • ts-mongo

Credits

MonType is a Swimlane open-source project; we believe in giving back to the open-source community by sharing some of the projects we build for our application. Swimlane is an automated cyber security operations and incident response platform that enables cyber security teams to leverage threat intelligence, speed up incident response and automate security operations.

Keywords

FAQs

Package last updated on 13 Apr 2017

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc