1.2.1 • Published 5 years ago

@dekproject/mongodb v1.2.1

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

@dekproject/mongodb

MongoDB interface plugin for DEK

What does this plugin do?

  • Control configuration for connection to MongoDB in production development mode in a simplified way with dotenv
  • Performs connection implementation along the lines ES6 being pre requirement to start the project

Instalation

To install the bootstrap we recommend using the CLI

$ yarn add @dekproject/mongodb --save
$ nano .env

In the .env file add the following settings

MONGO_USER=
MONGO_PASSWORD=
MONGO_HOST=localhost
MONGO_PORT=27017
MONGO_DB=dek

For applications with cluster usage in MongoDB

MONGO_USER=
MONGO_PASSWORD=
MONGO_PATH=mongodb://mongo-01:27017,mongo-02:27017/dek?replicaSet=dek&readPreference=secondaryPreferred
MONGO_DB=dek

Usage

Using direct

$ npm i @dekproject/scope

Using in the standard DEK skeleton

import { $, app, mongodb } from "@dekproject/scope";

app.get("user", (req, res) => {
    mongodb.users.find({}).toArray((err, docs) => {
        if(err) res.status(500).send(err).end();
        else res.send(docs).end();
    });
});

$.wait("mongodb").then(() => {
    app.listen(PORT, () => {
        console.log(`App listening on port ${PORT}!`);
    });
});
1.2.1

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.5

5 years ago

1.0.3

5 years ago