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

nd-mongo

v0.0.3

Published

node-dependency plugin to help expose mongoose's collections on a HTTP interface

Downloads

2

Readme

nd-mongo

node-dependency plugin to help expose mongoose's collections on a HTTP interface

This node-dependency plugin helps you expose Mongo Collection though a HTTP API.

Installation

$ npm install nd-mongo --save

You also need node-dependency and nd-express-plugin installed in your project.

How it works

This plugin will depend upon 'MongoModels', so you need to create a file to expose this dependency.
You can inject a dependency Mongoose which is the mongoose object.

MongoModels.js

function MongoModels (Mongoose) {
    return [{
        schema : {
            name : String
        },
        name : "User",
        url : "/user"
    }];
}

module.exports = MongoModels

This function should return and Array containing all your Collections definitions.

A Collection Definition:

  schema - used to instantiate a Mongoose Schema.
  name - your collection's name.
  url - the url appended to the server's base url

The following Object defines a Collection named 'User' to be served at <base_url>/user with the Schema with a property name of type String.

{
    schema : {
        name : String
    },
    name : "User",
    url : "/user"
}

After loading this Object, nd-mongo will setup a few urls to access the Collection's Documents:

URLs

Get all Documents:
/user/
with method GET - Optional limit and offset url parameters
Example:

    curl -H "Content-Type: application/json" -X GET http://localhost:9999/user?limit=1&offset=2

Update a Document:
/user/
with method PUT, requires a request body - The body should contain _id prop and the properties to update

Create a Document:
/user/
with method POST, requires a request body - The body will be saved as a new Document
Example:

    curl -H "Content-Type: application/json" -X POST -d '{"name":"Soem Name"}' http://localhost:9999/user/

Get by ID:
/user/:id
with method GET, requires id
Example:

    // This will get the Document with _id `559563e4670059eb769fdbd3`
    curl -H "Content-Type: application/json" -X GET http://localhost:9999/user/559563e4670059eb769fdbd3

Delete a Document:
/user/:id
with method DELETE, requires id of the Document to be deleted Example:

    // This will delete the Document with _id `559563e4670059eb769fdbd3`
    curl -H "Content-Type: application/json" -X DELETE http://localhost:9999/user/559563e4670059eb769fdbd3

Find Documents:
/user/find
with method POST, requires a request body which will be used as a mongoose query - Optional limit and offset url parameters
Example:

    // This will query for all Documents with name 'Some Name'
    curl -H "Content-Type: application/json" -X POST -d '{"name":"Some Name"}' http://localhost:9999/user/find