2.3.0 • Published 6 years ago

mongo-ts-wrapper v2.3.0

Weekly downloads
4
License
MIT
Repository
github
Last release
6 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

6 years ago

2.2.1

7 years ago

2.2.0

7 years ago

2.1.3

7 years ago

2.1.2

7 years ago

2.1.0

7 years ago

2.0.6

7 years ago

2.0.5

7 years ago

2.0.4

7 years ago

2.0.3

7 years ago

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.0.13

7 years ago

1.0.12

7 years ago

1.0.11

7 years ago

1.0.10

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago