npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

monetdb-rest

v0.1.1

Published

MonetDB RESTful Proxy

Downloads

6

Readme

MonetDB RESTful Proxy

Build Status npm version Dependency Status

A proxy for MonetDB that provides a RESTful interface and extended documents support. It currently intended for as an experiment, rather than a complete replacement of the MonetDB SQL interface and MAPI protocol. Having said that, the proxy is meant to be extensible (see below).

Installation and start

Run npm install [-g] monetdb-rest to install any dependencies

Run npm start to start the MonetDB RESTful Proxy. The Node.js process will start on port 8888.

API

Database management

HTTP method | URI path | Body | Description --- | --- | --- | --- GET | /database/_all | | List all attached databases PUT | /database/<database-name> | Content-Type: application/json { "host" : "<hostname>", "port" : <port>, "user" : "<username>", "password" : "<password>" } | Attach a database with the specified name and connection DELETE | /database/<database-name> | | Detach the database with the specified name GET | /database/<database-name>/_connection | | Show the database connection info GET | /database/<database-name>/_api | | List all available endpoints at database level

Data management

HTTP method | URI path | Body | Description --- | --- | --- | --- GET | /database/<database-name>/schema/_all | | List all schemas GET | /database/<database-name>/schema/<schema-name>/_api | | List all available endpoints at schema level GET | /database/<database-name>/schema/<schema-name>/table/_all | | List all available tables for the schema POST | /database/<database-name>/schema/<schema-name>/table/ | Content-Type: application/json { "table" : "<table-name>", "columns" : { "<column-name-1>": "<data-type-1>", "<column-name-2>": "<data-type-2>" }} | Create a new table with the specified name and columns GET | /database/<database-name>/schema/<schema-name>/table/<table-name>/info | | Show table info GET | /database/<database-name>/schema/<schema-name>/table/<table-name>/all | | Get all rows and columns POST | /database/<database-name>/schema/<schema-name>/table/<table-name> | Content-Type: application/json { "values": [<value-1>, <value-2>]} | Insert values into table POST | /database/<database-name>/schema/<schema-name>/table/<table-name> | Content-Type: application/json { "values" : { "<column-name-1>": <value-1>, "<column-name-2>": <value-2> }}| Insert values into the specified columns on a table GET | /database/<database-name>/schema/<schema-name>/table/<table-name>?columns=<column-name-1>,<column-name-2> | | Get all values for the specified columns GET | /database/<database-name>/schema/<schema-name>/table/<table-name>?filter<column-name>=<value> | | Get all matching the filter GET | /database/<database-name>/schema/<schema-name>/table/<table-name>?orderBy=<column-name> | | Order the results but a column-name GET | /database/<database-name>/schema/<schema-name>/table/<table-name>?limit=<value> | | Limit the results to the specified number of first values PUT | /database/<database-name>/schema/<schema-name>/table/<table-name>?filter<column-name>=<value> | Content-Type: application/json { "<column-name-1>": <updated-value-1>, "<column-name-2>": <updated-value-2>} | Update the records matching the filter with the specified values DELETE | /database/<database-name>/schema/<schema-name>/table/<table-name> | | Delete the records matching the filter GET | /database/<database-name>/schema/<schema-name>/view/_all | | Shows all views for the specified schema POST | /database/<database-name>/schema/<schema-name>/view/ | Content-Type: application/json { "view": "<view-name>", "query": "<SQL-query>"} | Create a view with the specified name and SQL query GET | /database/<database-name>/schema/<schema-name>/view/<view-name>/_info | | Get the view info GET | /database/<database-name>/schema/<schema-name>/view/<view-name> | | Get the view records DELETE | /database/<database-name>/schema/<schema-name>/view/<view-name> | | Delete the view GET | /database/<database-name>/query?q=<query> | | Executes the URI-encoded SQL query POST | /database/<database-name>/query | Content-Type: text/plain SQL Query | Executes the raw SQL query in the body GET | /database/<database-name>/function/<function-name>?a=<value-1>&b=<value-2> | | Calls the SQL function with the provided parameters

Strings, spaces and nulls

  • String values with white space in a path parameters need to be URL encoded, e.g. /database/demo/schema/sys/table/cities?filter_city=Amsterdam%20Zuid
  • JSON null values are passed to the database as null values.

Document management

To start working with document one must first create a schema documents and a table documents with the following columns: _id int, body json. If the schema and table are no found in the attached database, the proxy can create them with a POST to /database/<database-name>/document/_init.

HTTP method | URI path | Body | Description --- | --- | --- | --- POST | /database/<database-name>/document/_init | | Initialise the document storage schema and table GET | /database/<database-name>/document/_all | | List all documents POST | /database/<database-name>/document/ | Content-Type: application/json Document body | Store a document with a auto-generated ID PUT | /database/<database-name>/document/<document-id> | Content-Type: application/json Document body | Store or update a document with the specified document ID. If the document exits, replace it GET | /database/<database-name>/document/<document-id> | | Get the document with the specified document ID DELETE | /database/<database-name>/document/<document-id> | | Delete the document with the specified document ID GET | /database/<database-name>/document/<document-id>/_find?<key>=<value> | | Get all documents matching the specified filter

Extensions

The MonetDB RESTful Proxy is designed to be extensible, allowing developers to write their own endpoints and interfaces and dropping in place.

Routes are handed by the Express Node.js framework router. The routes directory contains all the URL path routes and endpoints in hierarchical order. Each directory contains an index.js file which scans the directory contents and registers all files as routes, ignoring only the entries prefixed with _. Endpoints or sub-routes are defined in each of the files or sub-directories. If you want to add another level to the route, use the addRoutes function from lib/router-loader.js, to add a new set of endpoints at the desired level.

For example, the routes directory contains an index.js that scans the directory and a database.js file (added by the index) for database level operations - like creating a new database connection. In database.js a new rotue is added using addRoutes, referring to routes/_database directory and its contents. This adds the document, function, query and schema routes, which all appear as URL paths for specific database, as seen in the API documentation above.

If you want to add a new route, e.g. join, you need to write a join.js, following the example of another 'query.js', and drop the file in routes/_database. After restarting the database you will be able to execute queries to the defined endpoints at /database/<database-name>/join.

Alternatively, if you want to extend the search operations that can be performed on all documents, you need only work on the routes/_database/_document/find.js file.