Skip to content

VaqueroFontenla/koop-provider-mongodb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 that demonstrates how to build a Koop Provider.

Required:

Install

To install/use this provider you first need a working installation of Koop. For information on using Koop, see https://github.com/esri/koop.

Getting started

  1. Create a directory:
$ cd ~/Desktop
$ mkdir my_project
$ cd my_project
  1. To execute in the project:
$ 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:
$ touch server.js
const config = require('config')
const Koop = require('koop');

const koop = new Koop(config);
const FeatureServer = require('koop-output-geoservices')
const Provider = require('koop-provider-mongodb')

koop.register(Provider);
koop.register(FeatureServer);

// In Local Development, be aware that port has to be greater than 1024 ( Unpriviledge port)
koop.server.listen(8080);
  1. Create configuration:
$ mkdir config
$ cd config
$ touch default.json
  1. Fill default.json with proper data
{
 "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.
$ npm i koop@3.9.4
$ npm i koop-provider-mongodb
  1. Start
node server.js
  1. If you need to debug it
node --inspect-brk server.js

node_inspect

Usage

By default, Koop will start listening on http://localhost:8080.

You can issue a request by using:

$ curl http://localhost:8080/mongodb/:id/FeatureServer

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

Resources

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •