# @ethiclab/crud-mongo

> A module for creating REST endpoints for mongo collections

Latest version **1.0.7** (published 2020-10-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install @ethiclab/crud-mongo
pnpm add @ethiclab/crud-mongo
yarn add @ethiclab/crud-mongo
bun add @ethiclab/crud-mongo
```

## 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.0.7 |
| Published | 2020-10-07 |
| First published | 2020-07-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 8.8 KB |
| Known vulnerabilities | 0 (+7 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | EthicLab Team |
| Maintainers | ethiclab |
| Keywords | mongo, rest |

## Links

- npm: https://www.npmjs.com/package/@ethiclab/crud-mongo
- Repository: https://github.com/ethiclab/crud-mongo
- Homepage: https://github.com/ethiclab/crud-mongo#readme
- Issues: https://github.com/ethiclab/crud-mongo/issues
- npm.io page: https://npm.io/package/@ethiclab/crud-mongo

## Dependencies (1)

- [mongoose](https://npm.io/package/mongoose.md) ^5.9.25

## Alternatives

- [angular-pipes](https://npm.io/package/angular-pipes.md) — 5.6K weekly downloads
- [@ng-web-apis/midi](https://npm.io/package/@ng-web-apis/midi.md) — 2.6K weekly downloads
- [happn-3](https://npm.io/package/happn-3.md) — 1.6K weekly downloads
- [@opensip-cli/lang-go](https://npm.io/package/@opensip-cli/lang-go.md) — 1.2K weekly downloads
- [btrz-health-check](https://npm.io/package/btrz-health-check.md) — 474 weekly downloads

## Recent versions

- 1.0.7 (latest) — 2020-10-07
- 1.0.6 — 2020-10-06
- 1.0.5 — 2020-09-18
- 1.0.4 — 2020-08-05
- 1.0.3 — 2020-07-24
- 1.0.2 — 2020-07-24
- 1.0.1 — 2020-07-24
- 1.0.0 — 2020-07-24

## README

# crud-mongo

    npm install @ethiclab/crud-mongo

# usage

A simple example, with no actual express router, only for testing purposes.

```javascript
const crud = require("@ethiclab/crud-mongo");
(async () => {
  const controller = await crud({
    mongoUrl: 'mongodb://localhost',
    databaseName: 'sys',
    root: '/',
    router: {
      get: () => {
        return {}
      },
      post: () => {
        return {}
      },
      put: () => {
        return {}
      },
      delete: () => {
        return {}
      }
    },
    col: 'mycollection'
  })
  const x = await controller.create({
    name: 'test object'
  })
  console.log(x)
})()
```

An example using express router.

```javascript
const express = require('express')
const app = express()
const router = express.Router()

crud({
    mongoUrl: 'mongodb://localhost',
    databaseName: 'sys',
    root: '/',
    router: router,
    col: 'mycollection'
})

app.use((req, res, next) => {
  router(req, res, next)
})

app.listen(12345)
```

Then, you can visit:

http://localhost:12345/mycollection

You can also use, for instance, Postman, for creating, updating and deleting records.

The following endpoints are defined:

    GET /mycollection
    POST /mycollection
    GET /mycollection/:id
    PUT /mycollection/:id
    DELETE /mycollection/:id

# where are the schemas?

This is a low level library for storing arbitrary documents with arbitrary properties
in order to support new properties, therefore, we decided not to add schema support
at this level.

# test

    docker run --name localmongo --rm -d -p 27017:27017 mongo
    npm test

---
_Source: https://npm.io/package/@ethiclab/crud-mongo · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
