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

nevermind-collections

v1.1.4

Published

## Contents * [Server](#server) * [For MySQL Developers](#mysql-dev) * [Add More Routes](#routes) * [Use Database On Your Own](#use-db) * [Register and Login](#register-login) * [Restful API](#rest)

Downloads

10

Readme

Nevermind Collections

Contents

Foreword

It has always been a pain while starting the back-end of a project especially if you are prototyping. nevermind-collections is a part of an ongoing project called NevermindJS.

You can easily connect nevermind-collections to your database and turn it to a RESTful api in no time! If you would not like to install a database to your server or want your backend to be standalone simple use nedb adapter which is built on a flat file database. All your collections will be kept in json files.

Please feel free to contribute and let me know about the features you may need for a better nevermind-collections!

Project can also be found on Github

@kucukkanat

Server

To Create a Server

var Nevermind = require('nevermind-collections')

var Server = new Nevermind(8080)
//Initiate the database
Server.nedb()
Server.eventListener.on("insert:users",function(e){
  console.log(e,' Inserted!')
})

For Mysql Developers

If you are using mysql adapter initiate connection with :

    Server.mysql({
        host     : 'localhost',
        user     : 'me',
        password : 'secret',
        database : 'my_db'
      })

For mysql developers /collection paths are not exposed to clients since client can run any query due to security reasons. Mysql developers can add routes and set the actions for each endpoint themselves like :

    Server.Router.get('/users',function(req,res){
      Server.Adapter.table('users').query('SELECT * FROM users')
      .then(function(err,rows){
        res.send(rows)
        })
      })

Adding more routes

The server instance also exposes express application so that user can add her own routes. (Here we encourage female developers, no typo ;) )

Server.Router.get('/test',function(req,res){
  res.send('Hello world!')
  })

Using database on your own (Only works with nedb adapter!)

Get major people :

  Server.Adapter.table('someTableName').find({age:{$gt:18}})
  .then(function(err,result){
    //Do something with the result
  })

Insert something to table :

  Server.Adapter.table('someTableName').insert({productName:"Armchair":price:25},function(err,result){
    //Do something with the result
  })

Register and login (Only works with nedb!)

First you need to register an account :

post /register

{username:"",password:"",email:""}

Then login to acquire a token :

post /login

{username:"",password:""}

It is very important that you keep the token so you can use /collection/* endpoints !!!


Restful Api Endpoints (Only works with nedb!)

[POST] /collection/insert/:collectionName

Parameters :
{
  "item":{}
}

[POST] /collection/update/:collectionName

Parameters :
{
  "item":{},
  "query":{}
}

[POST] /collection/remove/:collectionName

Parameters :
{
  "query":{}
}

[POST] /collection/find/:collectionName

Parameters :
{
  "query":{}
}
TO-DO
  • [x] Add event emitters for each action
  • [ ] Add before event emitter
  • [x] Documentation for server instance
  • [ ] Adapters for different databases
    • [x] MySQL
    • [ ] MongoDB
    • [x] NedDB