Skip to the content.

Setup our sample Node.js application

Application details

HTTP verb URI Action
GET /message list all messages
GET /message/ID get message with ID
POST /message create a new message
PUT /message/ID modify message with ID
DELETE /message/ID delete message with ID

Setup

config/model.js:
module.exports.models = {
connections: 'sails-mongo',
 migrate: 'safe'
};
config/connections.js:
module.exports.connections = {
  mongo: {
     adapter: 'sails-mongo',
     url: process.env.MONGO_URL || 'mongodb://localhost/messageApp'
  }
};

Test the application in command line

[]
[
  {
    "text": "hello",
    "createdAt": "2015-11-08T13:15:15.363Z",
    "updatedAt": "2015-11-08T13:15:15.363Z",
    "id": "5638b363c5cd0825511690bd" 
  },
  {
    "text": "hola",
    "createdAt": "2015-11-08T13:15:45.774Z",
    "updatedAt": "2015-11-08T13:15:45.774Z",
    "id": "5638b381c5cd0825511690be"
  }
]
[
  {
    "text": "hey",
    "createdAt": "2015-11-08T13:15:15.363Z",
    "updatedAt": "2015-11-08T13:19:40.179Z",
    "id": "5638b363c5cd0825511690bd"
  }
]