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 🙏

© 2025 – Pkg Stats / Ryan Hefner

fastcrud

v0.0.0

Published

Node module to build quickly api, views to display models, easy integration with Backbone, etc.

Readme

FastCrud

FastCrud is Node.js module that makes development of CRUD operations faster, allowing to focus on frontend.

It works with Express and Mongoose.

Some features:

  • you can define a model simply by its default values. It creates automatically from them the corresponding mongoose Schema

  • you can add API for defined models simply in one line of code. It generates automatically urls and corresponding methods

  • you can use generic views to automatically generate urls and corresponding http request handlers and focus only on template to display, modify and create models, with just few lines of code. Generic views supported are: ListView (to list instances of a model), DetailsView (to display single model), CreateView and UpdateView

How to use it

Suppose you have a Student model with nested School model.

Define a model

Define a model calling FastCrud.Model function and passing an object of default values.


var FastCrud=require('./fastcrud')

var StudentModel=FastCrud.Model({
  Student:{
    name: 'Giovanni Johnson',
    age: 18,
    School: {
      name: 'Standford',
      address: 'Stand street'
    }
  },
})

Create, save, update and remove model

You can invoke FastCrud.get(name_of_model) function to get mongoose model. Example:


var Student=FastCrud.get('Student')
, School=FastCrud.get('School')

var school=new School({
  name: 'Roma 3',
  address: 'via della Vasca Navale'
})

var student=new Student({
  name: 'Marco DiLillo',
  age: 24,
  school: school
}).save(function(err,doc){
  console.log(err,doc);
})

Define API to handle models

Use setAPI(app) of a defined model, it automatically defines url and corresponding methods to handle instances via GET, PUT, POST, DELETE http methods.


StudentModel.setAPI(app)

Generated urls are:

  • /api/student/ - to get a list of all student models
  • /api/student/:_id/ - to get a single instance model by _id attribute via GET http method
  • /api/student/:_id/ - to save or modify a single istance model by _id attribute via POST/PUT http methods
  • /api/student/:_id/ - to delete a single instance model by _id via DELETE http method

Use generic view to build quickly page that display models

Use setGenericViews(app,options) to quickly define urls and corresponding routes to display models. It automatically generate corresponding urls, like:

  • /student/ (GET http method): url to list all Student models
  • /student/ (POST http method): url to create new Student model
  • /student/_id/ (GET http method): url to display a Details view about one Student model
  • and so on (...under construction...)

Parameters are:

  • app: the app object defined normally in app.js file
  • options: to specify what generic views it defines, passing for every generic view a template parameter that specify the file used to display models

Example:


StudentModel.setGenericViews(app,{
  ListView: {
    template: './students/students.jade'
  },
  DetailsView:{
    template: './students/student.jade'
  }
})

Example of jade templates for ListView:


- for student in models
	p 
		a(href='/student/#{student._id}/') #{student.name} 

Example of jade templates for DetailsView:


	p Name: #{model.name} 
	p School: #{model.school[0].name}