2.3.0 • Published 5 years ago

mongo-ts-wrapper v2.3.0

Weekly downloads
4
License
MIT
Repository
github
Last release
5 years ago

This package provides the following classes to use in Typescript (under the hood we use the native mongo javascript client):

import { Collection, Container, Model } from "mongo-ts-wrapper";

Simply instance your mongo context with:

let repository: Container = new Container("mongodb://localhost:27017/database"); //Use your database uri

Write your models with annotations:

@Collection("user") //The name of your collection in mongo
class User extends Model<User> {
    name: string;
    password: string;
}

@Collection("roles")
class Role extends Model<Role> {
    name: string;
    type: string;
}

Add your models to your repository:

await repository.addModels([User, Role]);  //This is a promise, be careful!

And use your models wherever you need:

let result = await User.insertOne({email: "john.doe@mail.com", password: "123"});  //This is a promise

if(result.result.ok)
  doSomethingCool();

let user = await User.findOne({email: "john.doe@mail.com"})

Current implemented methods, completely compatible with native javascript mongo client behaviour:

  1. findOne
  2. findAll
  3. insertOne
  4. insertMany
  5. updateOne //with default upserts
  6. updateMany //with default upserts
  7. remove
  8. distinct
2.3.0

5 years ago

2.2.1

6 years ago

2.2.0

6 years ago

2.1.3

6 years ago

2.1.2

6 years ago

2.1.0

6 years ago

2.0.6

6 years ago

2.0.5

6 years ago

2.0.4

6 years ago

2.0.3

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.0.13

6 years ago

1.0.12

6 years ago

1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago