Class: Mongo

arpen/services/mongo~ Mongo

Mongo service

mongodb module is required

Add to your config:
// MongoDB servers
mongo: {
  main: {
    host: 'localhost',
    port: 27017,
    user: 'username',
    password: 'password',
    database: 'dbname',
    pool_size: 100,
  },
},

new Mongo(config, logger, util)

Create the service
Parameters:
Name Type Description
config object Config service
logger Logger Logger service
util Util Util service

Members


<static> provides :string

Service name is 'mongo'
Type:
  • string

<static> requires :Array.<string>

Dependencies as constructor arguments
Type:
  • Array.<string>

<static> lifecycle :string

This service is a singleton
Type:
  • string

<static> datetimeFormat :string

Format of date/time string
Type:
  • string

Methods


<async> connect(name)

Obtain Mongo client
Parameters:
Name Type Default Description
name string 'main' Server name in config
Returns:
Resolves to connected MongoClient instance
Type
Promise