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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@wsc-company/database-mongo

v1.0.0

Published

Pacote de Com conexão e modelos de regras para o mongodb

Downloads

2

Readme

Database MongoDb

Pacote de Com conexão e modelos de regras para o mongodb

Entity and Provider

  • Entity

As Entities básicamente são os modelos de dados, com os campos, preenchimento default, qual campo é obrigatório ou unico, etc.

  • Provider

Os providers são os detentores das regras de db como fazer uma query? O provider quem sabe, como pegar um user pelo e-mail ou pelo cpf? o provider que sabe.

Em outras palavras o provider é a ponte entre o restante do código e a Entity.

Usages

  • new entity example

Sempre que for criar uma nova entity siga a regra de extender o BaseMongoDbEntity e implementar o schema do mesmo contexto como no exemplo o schema correto é IExampleSchema

Então crie um novo metodo na factory para instanciar a nova entity

import { IExampleSchema } from '@wsc-company/types'
import { BaseMongoDbEntity as BaseEntity } from './baseMongoDbEntity'
import { prop } from '@hasezoey/typegoose'

export class ExampleEntity extends BaseEntity implements IExampleSchema {
  @prop({ required: true })
  name: string
}
  • new provider example

Sempre que for criar um novo provider siga a regra de extender o BaseMongoDbProvider e implementar o IDataBaseProvider.

Então crie um metodo na factory para instanciar esse provider

import { IDataBaseProvider } from '@wsc-company/types'
import { BaseMongoDbProvider } from './baseMongoDbProvider'

export class ExampleProvider
  extends BaseMongoDbProvider
  implements IDataBaseProvider {}

export class FactoryMongoDbProvider {
  static getExampleProvider(db: string = DEFAULT_MONGODB): ExampleProvider {
    return new ExampleProvider(
      new MongoConnection(db),
      FactoryMongoDbEntity.getExampleEntity(),
    )
  }
}
  • BaseProvider methods

Os metodos dentro do BaseProvider foram inspirados nos metodos do próprio mongo então a forma de usar é bem parecida, para maiores informações sobre como usa-los procure em /test dentro do próprio projeto