Posts

Showing posts with the label CRUD

REST CRUD Back-end Services in Seconds Without Writing One Line of Code

Create a Services Back-end in seconds with Node.js and Sails MVC Frameowrk Scenario: You are a front-end developer that would like to test your newly developed user interface, by pointing to some real back end services. In today enterprise world, this can be a very time consuming and expensive challenge. Depending on your company structure, you might have to involve your management for approvals, procurement, and also the infrastructure, security, networking, back-end development, database teams, etc. But all you need is some back-end service that can allow you to insert and retrieve some data, without wasting a month to get it accomplished. This is how can you get it done without writing one line of code. On your local machine or a development server (linux, mac os, windows): 1. Install node.js (http://nodejs.org/) sudo yum install nodejs npm 2. Install sails (http://sailsjs.org/) sudo npm -g install sails 3. Create new Sails Project sails new TestBackend 4. ...

Node.js RESTful CRUD (Express & MongoDB)

/* Server */ //Import Express Framework. Install: npm install express var express = require ( 'express' ); var app = express (); /*bodyParser Parses the contents of the request body. */ app . use ( express . bodyParser ()); /* methodOverride: works with bodyParser and provides DELETE and PUT methods along with POST. You can use app.put() and app.delete() rather than detecting the user’s intention from app.post(). This enables proper RESTful application design. However the form/request will require a hidden input _method that can be put or delete*/ app . use ( express . methodOverride ()); /* Database */ var mongoose = require ( 'mongoose' ); //Import MongoDb 'driver'.Install: npm install mongoose mongoose . connect ( 'mongodb://localhost/bookmarks' ); var Schema = mongoose . Schema ; var ObjectId = Schema . ObjectId ; /* Models */ var Bookmark = new Schema ({ name : { type : String , required : true , trim ...