Fewer

Fewer

  • Getting Started
  • API
  • Github
  • Help

›Introduction

Introduction

  • Getting Started
  • Installation
  • Create an Association

Adapters

  • Postgres Adapter
  • MySQL Adapter

Advanced Topics

  • Multiple Databases

API Reference

  • API Reference
  • Database
  • Repository
  • Associations
  • Custom Pipes

Getting Started

We will walk you through adding Fewer to an existing Node.js application.

Installation

To install the latest version of fewer:

npm install --save fewer

You'll likely also want to globally install the fewer CLI to help scaffold things out:

npm install --global @fewer/cli

Initialize your project

The fewer CLI can add support to your existing project

fewer init

Fewer will generate the following folders and files into your project.

my-project/
    src/
        migrations/
            example.ts
        repositories/
            index.ts
            example.ts
        db.ts
        schema.ts

You can rename these files and folders, they are only generated based on community conventions. Fewer does not require or enforce any project structure.

Open the db.ts file to configure your database connection:

import { createDatabase } from 'fewer';
import { MySQLAdapter as Adapter } from '@fewer/adapter-mysql';

export default createDatabase({
  adapter: new Adapter({
    host: 'localhost',
    port: 3306,
    username: 'test',
    password: 'test',
    database: 'test',
  }),
});

You'll need to initiate the connection to the database in your code, so open up the entry point to your application, and add the following lines:

import db from './db';

db.connect();
Installation →
Fewer
Docs
Getting Started (or other categories)Guides (or other categories)API Reference (or other categories)
Community
Stack OverflowProject ChatTwitter
More
GitHub
Copyright © 2019