New:Microsoft Teams Notifications Are Now Available in Socket.Learn more
Get Started

fastify-typeorm

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fastify-typeorm

fastify plugin for typeorm

Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

fastify-typeorm

Fastify plugin to work with TypeORM

install

npm install fastify-typeorm

Usage

const fastify = require('fastify')();
const ftypeorm = require('fastify-typeorm');
// ftypeorm.many to use multiple connections

const typeormConfig = {
  instance: 'db', // the name of fastify plugin instance. defaults to db
  typeormConfig // this is an optional param, see: http://typeorm.io/#/using-ormconfig
};

fastify.register(ftypeorm, typeormConfig).ready();

fastify.get('/',async function(req, res) =>{
  // here you can use your connection just like any typeorm connection
  const repo = fastify.db.getRepository(Model) // or fastify.db[i].getRepository
  return repo.find()
})

fastify.listen(3000, () => {
  console.log('> listening on port 3000');
});
  • instance: (optional) the name of instance will be mapped to fastify, default is db
  • typeormConfig: all typeorm configurations, you can see here.

Keywords

typeorm

FAQs

Package last updated on 12 Nov 2018

Related posts