# loopback-component-storage-postgres

> [![Build Status](https://travis-ci.org/jdrouet/loopback-component-storage-postgres.svg)](https://travis-ci.org/jdrouet/loopback-component-storage-postgres) [![Dependency Status](https://david-dm.org/jdrouet/loopback-component-storage-postgres.svg)](https:

Latest version **1.1.3** (published 2016-04-04) · ISC license · 0 weekly downloads

## Install

```sh
npm install loopback-component-storage-postgres
pnpm add loopback-component-storage-postgres
yarn add loopback-component-storage-postgres
bun add loopback-component-storage-postgres
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.3 |
| Published | 2016-04-04 |
| First published | 2016-01-20 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 10 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Jérémie Drouet |
| Maintainers | jdrouet |
| Keywords | loopback, postgres, connector, storage |

## Links

- npm: https://www.npmjs.com/package/loopback-component-storage-postgres
- npm.io page: https://npm.io/package/loopback-component-storage-postgres

## Dependencies (10)

- [pg](https://npm.io/package/pg.md) ^4.5.1
- [async](https://npm.io/package/async.md) ^2.0.0-rc.2
- [debug](https://npm.io/package/debug.md) ^2.2.0
- [busboy](https://npm.io/package/busboy.md) ^0.2.13
- [lodash](https://npm.io/package/lodash.md) ^4.6.1
- [bluebird](https://npm.io/package/bluebird.md) ^3.3.4
- [formidable](https://npm.io/package/formidable.md) ^1.0.17
- [string_decoder](https://npm.io/package/string_decoder.md) ^0.10.31
- [pg-large-object](https://npm.io/package/pg-large-object.md) ^1.0.1
- [loopback-connector](https://npm.io/package/loopback-connector.md) ^2.3.0

## Alternatives

- [localforage](https://npm.io/package/localforage.md) — 6.2M weekly downloads
- [localforage-observable](https://npm.io/package/localforage-observable.md) — 30.8K weekly downloads
- [@y/y](https://npm.io/package/@y/y.md) — 30.1K weekly downloads
- [@metaobjectsdev/render](https://npm.io/package/@metaobjectsdev/render.md) — 3.5K weekly downloads
- [@ledgerhq/coin-algorand](https://npm.io/package/@ledgerhq/coin-algorand.md) — 1.1K weekly downloads

## Recent versions

- 1.1.3 (latest) — 2016-04-04
- 1.1.2 — 2016-03-24
- 1.1.1 — 2016-03-14
- 1.1.0 — 2016-02-25
- 1.0.1 — 2016-01-26
- 1.0.0 — 2016-01-20

## README

# loopback-component-storage-postgres
[![Build Status](https://travis-ci.org/jdrouet/loopback-component-storage-postgres.svg)](https://travis-ci.org/jdrouet/loopback-component-storage-postgres)
[![Dependency Status](https://david-dm.org/jdrouet/loopback-component-storage-postgres.svg)](https://david-dm.org/jdrouet/loopback-component-storage-postgres)
[![codecov.io](https://codecov.io/github/jdrouet/loopback-component-storage-postgres/coverage.svg?branch=master)](https://codecov.io/github/jdrouet/loopback-component-storage-postgres?branch=master)

LoopBack storage postgres component provides Node.js and REST APIs to manage binary contents using Postgres Large Object

## Installation

Install the storage component as usual for a Node package:

```bash
  npm install --save loopback-component-storage-postgres
```



## Using it

Create a table to store file descriptions

```sql
  CREATE TABLE "my-tabe-to-store-files" (
    id SERIAL PRIMARY KEY,
    container TEXT NOT NULL,
    filename TEXT NOT NULL,
    mimetype TEXT,
    objectid INTEGER UNIQUE NOT NULL
  );
```

Edit you datasources.json and add the following part

```javascript
"pg_file": {
  "name": "pg_file",
  "connector": "loopback-component-storage-postgres",
  "host": "localhost",
  "port": 5432,
  "database": "test",
  "table": "my-table-to-store-files",
  "username": "test-user",
  "password": "test-password"
}
```

And the you can use it as a datasource of your model.

## API

Description                                                   | Container model method                    | REST URI
--------------------------------------------------------------|-------------------------------------------|--------------------------------------------
List all containers                                           | getContainers(callback)                   | GET /api/<model>
Get information about specified container                     | getContainer(container, callback)         | GET /api/<model>/:container
Create a new container                                        | createContainer(options, callback)        | PORT /api/<model>
Delete specified container                                    | destroyContainer(options, callback)       | DELETE /api/<model>/:container
List all files within specified container                     | getFiles(container, callback)             | GET /api/<model>/:container/files
Get information for specified file within specified container | getFile(container, file, callback)        | GET /api/<model>/:container/files/:file
Delete a file within a given container by name                | removeFile(container, file, callback)     | DELETE /api/<model>/:container/files/:file
Upload one or more files into the specified container         | upload(container, req, res, callback)     | POST /api/<model>/:container/upload
Download a file within specified container                    | download(container, file, res, callback)  | GET /api/<model>/:container/download/:file

---
_Source: https://npm.io/package/loopback-component-storage-postgres · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
