rubik-mongodb

1.0.0 • Public • Published

rubik-mongodb

Small kubik for native mongodb driver connections. Useful in small scripts or services.

Configuration

module.exports = {
	url: 'mongodb://localhost:27017', // connection url
	db: 'test', // database name
	collections: [], // names of connected collections, it's just aliases. Every name will be converted into a property with the same name
	options: { // connnection options
		minPoolSize: 5,
		maxPoolSize: 20,
		keepAlive: true
		// you could read a full list of available options at https://mongodb.github.io/node-mongodb-native/4.3/interfaces/MongoClientOptions.html
	}
};

constructor(names)

names is an array of strings — collection names.

const storage = new MongoDB(['Users', 'Roles']);
app.add(storage);

await app.up();

const users = storage.Users.find();
const roles = storage.Roles.find();

It's not necessary, you can access every collection throught db ↓

instance.db

Returns an instance of the connected db. See documentation here

Readme

Keywords

none

Package Sidebar

Install

npm i rubik-mongodb

Weekly Downloads

0

Version

1.0.0

License

Apache-2.0

Unpacked Size

15.3 kB

Total Files

7

Last publish

Collaborators

  • ya-kostik