0

I am a newbie in sails.js framework(and for node.js) and I have created myself an API from the address bar using sails.js features. my question is how do I transfer this data to mongodb so I can see it visually.

I have tried to follow this guide: https://www.npmjs.org/package/sails-mongo but its for 0.9 sails version(current version is 0.10) so that a lot of files that I needed to change has been modified and gone/renamed. I couldn't find an updated tutorial as well so if anyone can please write down how can I implement mongoDB to my sails project that would be wonderful.

2 Answers 2

2

In config/connections.js you need to configure your mongoDB connection. Then go to config/models.js, uncomment the connection property and set the name of your mongoDB connection.

Sign up to request clarification or add additional context in comments.

Comments

0

In config/connection.js, You can configure your MongoDb connection like this.

module.exports.connections = {
  MongoConnection: {
    adapter: 'sails-mongo',
    host: 'localhost',
    port: 27017,
    // user: 'username',
    // password: 'password',
    database: 'DB_Name'
  }
};

You need to install sails-mongo package using npm in your working folder.

Then in config/models.js, Add the name of your mongoDb connection like this:

module.exports.models = {                                                                          
   connection: 'MongoConnection',                                                                     
   migrate: 'alter'
};

Thats it, you are ready to go.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.