@fizz.js/node-mongodb
v1.0.0
Published
node-mongodb
Downloads
3
Readme
@fizz.js/node-mongodb
This is a MongoDB library for express.
install
add dependencies
into package.json
and run yarn install
configuration
please set mongodb
field into your config files.
{
"mongodb": {
"autoReconnect": true,
"noDelay": true,
"keepAlive": true,
"bufferCommands": false,
"useFindAndModify": false,
"useCreateIndex": true,
"useNewUrlParser": true,
"useUnifiedTopology": true,
"autoIndex": true,
"poolSize": 100,
"reconnectTries": 100,
"socketTimeoutMS": 10000,
"connectTimeoutMS": 10000,
"reconnectInterval": 500,
"bufferMaxEntries": 0,
"useCredentials": true,
"username": "root",
"password": "password",
"dbName": "test",
"host": "127.0.0.1",
"port": 27017,
"useReplica": false,
"replicaSet": "test_repl",
"replset": {
"readPreference": "SECONDARY"
},
"family": 4
}
}
test
yarn test
coverage
yarn cover
build
yarn build
docs
yarn docs
example
const fs = require('fs')
const path = require('path')
const inflector = require('inflected')
const basename = path.basename(__filename)
const ext = '.js'
const MongoDB = require('@fizz.js/node-mongodb')
fs.readdirSync(__dirname)
.filter(file => file.indexOf('.') !== 0 && file !== basename && file.slice(-3) === ext)
.map(file => {
file = file.replace(ext, '')
const schema = require(path.join(__dirname, file))
MongoDB.setSchema(file, schema)
})