@101-ways/core-mongo
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

@101-ways/core-mongo

MongoDb client accelerator package. It uses the Service Registry pattern to create a single object with APIs.

Features

  • starts server on port 8000 by default
  • debug logging with tracing metadata

Usage

import { load } from '@101-ways/core-mongo';

load([`${__dirname}/modules`]).then(async (sr) => {
  const collection = sr.mongo.db().collection('test');
  const list = await collection.find({}).toArray();
  console.log(list);
  sr.core.shutdown.run();
});

Basic example for creating a child package:

import { load as loadCore, type Registry } from '@101-ways/core-mongo';

export type { Registry };

export async function load<T extends Registry>(paths: string[] = [], sr?: T) {
  return loadCore([`${__dirname}/modules`, ...paths], sr);
}

Service Registry API

Everything in @101-ways/core and

Environment Variables

Everything in @101-ways/core and

  • MONGO_URI='mongodb://localhost:27017/test' - Mongo connection URI

Readme

Keywords

none

Package Sidebar

Install

npm i @101-ways/core-mongo

Weekly Downloads

3

Version

0.1.0

License

none

Unpacked Size

11.9 kB

Total Files

18

Last publish

Collaborators

  • borisovg