1.0.7 • Published 3 years ago

@fiquu/schema-loader-mongoose v1.0.7

Weekly downloads
46
License
MIT
Repository
github
Last release
3 years ago

@fiquu/schema-loader-mongoose

Build Status GitHub GitHub last commit npm (scoped) npm

Schema loader for Mongoose connections.

Installation

npm i @fiquu/schema-loader-mongoose

Usage

Use it to load your schemas into any Mongoose connection.

./configs/schemas.ts:

import { SchemasMap, SchemaLoaderOptions } from '@fiquu/schema-loader-mongoose';

// You could move the schema map to another sub-module...
import profile from '../schemas/profile';
import user from '../schemas/user';

const schemas: SchemasMap = new Map();

schemas.set('profile', profile);
schemas.set('user', user);

const options: SchemaLoaderOptions = {
  replace: false,
  clone: true
};

export default {
  schemas,
  options
}

./components/schemas.ts:

import { createSchemaLoader, SchemaLoader } from '@fiquu/schema-loader-mongoose';
import { Connection } from 'mongoose';

import { options, schemas } from '../configs/schemas';
import db from '../components/database';

const conn: Connection = db.connection('default');
const loader: SchemaLoader = createSchemaLoader(conn, options);

loader.loadAll(schemas);

export default loader;

Documentation

Please visit the documentation page for more info and options.

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.0

4 years ago