Fewer

Fewer

  • Getting Started
  • API
  • Github
  • Help

›API Reference

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

Database

Databases are responsible for performing queries against the underlying data store. They use a generalized Adapter interface to allow a multitude of database engines to be used.

createDatabase(config): Database

Creates and returns a new database instance. Once the application is ready, you can connect to the database using the connect() method on the database instance.

Arguments

  • config.adapter (Adapter): An instance of an Adapter to use to query and connect to the database.

Fewer currently provides the following adapters:

  • MySQL
  • Postgres

Database Methods

connect(): Promise

Attempts to establish a connection to the underlying database via the provided adapter. It returns a promise that is resolved once the connection is established. If the adapter is unable to successfully connect to the database, then the promise will be rejected.

Example

import { createDatabase } from 'fewer';

const database = createDatabase({
  adapter: myAdapter,
});

// Start the connection to the database.
database.connect();
← API ReferenceNext →
Fewer
Docs
Getting Started (or other categories)Guides (or other categories)API Reference (or other categories)
Community
Stack OverflowProject ChatTwitter
More
GitHubStar
Copyright © 2019