# koop-provider-mongodb

> A koop provider for mongodb

Latest version **1.0.0** (published 2018-10-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install koop-provider-mongodb
pnpm add koop-provider-mongodb
yarn add koop-provider-mongodb
bun add koop-provider-mongodb
```

## 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.0 |
| Published | 2018-10-24 |
| First published | 2018-10-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Loreto Vaquero Fontenla |
| Maintainers | loretovaquero |
| Keywords | koop, mongo, providers, docker |

## Links

- npm: https://www.npmjs.com/package/koop-provider-mongodb
- npm.io page: https://npm.io/package/koop-provider-mongodb

## Dependencies (4)

- [koop](https://npm.io/package/koop.md) ^3.9.4
- [mongodb](https://npm.io/package/mongodb.md) ^3.1.6
- [jsonfile](https://npm.io/package/jsonfile.md) ^5.0.0
- [csv-stream](https://npm.io/package/csv-stream.md) ^0.2.0

## 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
- [@temporal-architect/claude-plugin](https://npm.io/package/@temporal-architect/claude-plugin.md) — 335 weekly downloads

## Recent versions

- 1.0.0 (latest) — 2018-10-24

## README

# koop-provider-mongodb

This provider accesses a collection of documents in MongoDB, which translate into GeoJSON and Geoserviceslater.

This is provider was created from the [koop-provider-sample](https://github.com/koopjs/koop-provider-sample) that demonstrates how to build a Koop Provider.

## Required:
- [node.js](https://nodejs.org/es/)
- [mongoDB](https://docs.mongodb.com/manual/installation/)

## Install
To install/use this provider you first need a working installation of [Koop](https://github.com/Esri/koop). For information on using Koop, see https://github.com/esri/koop.

## Getting started

1. Create a directory:
```sh
$ cd ~/Desktop
$ mkdir my_project
$ cd my_project
```
1. To execute in the project:
```sh
$ npm init -y
```
*npm init -y: generate the package.json file with default options (without asking any questions)*

1. Create `server.js` and add content:

  ```sh
  $ touch server.js
  ```

  ```js

  process.on('SIGINT', () => process.exit(0))
  process.on('SIGTERM', () => process.exit(0))

  const Koop = require('koop')
  const koop = new Koop()

  const config = require('config')

  const provider = require('./index.js')
  koop.register(provider)

  const PORT = 8080
  koop.server.listen(PORT);

  ```

1. Create configuration:

 ```sh
$ mkdir config
$ cd config
$ touch default.json
```

1. Fill default.json with proper data
 ```js
{
  "mongodb": {
    "url": MongoDB connection string,
    "databasename": Database name,
    "collectionname": Collection name,
    "field_id": Request field (:id),
    "latitude": Latitude field database,
    "longitude":Longitude field database,
    "projectObj":fields to return in the documents that match the query filter.
    }
}
```

1. Install dependencies:
You must install the same version of `koop` as the `provider`.

  ```sh
  $ npm i koop@3.9.4
  $ npm i koop-provider-mongodb
  ```

1. Start

  ```sh
  node server.js
  ```
1. If you need to debug it

  ```sh
  node --inspect-brk server.js
  ```
![node_inspect](images/node_insp.png)

## Usage

By default, Koop will start listening on http://localhost:8080.

You can issue a request by using:

```sh
$ curl http://localhost:8080/mongodb/:id/FeatureServer0/query
```

Any query-parameters added to the request URL can accessed within getData and leveraged for data fetching purposes.

## Example

If you need to check some example, you can visit the [repository](https://github.com/VaqueroFontenla/koop-provider-mongodb.git)

## Resources
- http://koopjs.github.io/
- https://github.com/koopjs/koop-provider-file-geojson
- https://github.com/koopjs/koop-provider-sample.git

---
_Source: https://npm.io/package/koop-provider-mongodb · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
