How to use waterline outside sails? - node.js

I'm trying to use Waterline in my express application but how do I configure the database connection? I would like to use sails-mongo as an adapter but I'm not sure how to do it. Can any one help me with this problem?
Thanks

There is an example of using Waterline with Express in the Waterline Repo: https://github.com/balderdashy/waterline/blob/master/example/express/express-example.js

Related

Using Mongoose in Total.js

I tried a sample example of total.js for REST APIs and I noticed that its all using the NoSQL module. I need to convert this sample to work with MongoDB instead. Is it Possible to use mongoose for mongoDB to work in total.js
Yes and absolutely you can use Mongoose with Total.js. Only you need to rewrite processing of data in schemas, it's not hard. Try to look into the Mongoose documentation and start there.

Whats the equivalent of express.js "app.use()" in core node.js?

I am trying to use sessions in node.js, for that, i have to use connect-mongo package but in its documentation its been used with express's middleware function app.use() what if I want to use it in a project which does not use any framework like express.js
I have just started using node.js (or any backend) technology, so pardon for any mistakes
By Default Node http does not support middleware. But without express it is possible to do by defining your own chaining. Please refer this answer

What is the best practise of using same Model on several projects?

I create a ReactJS app using Sequelize and PostgreSQL database. I defined my models on my ReactJS API, but I need to use the same database (so the same models) on an other API.
How should I do so without writing again the definition of each model, because if I made a change, I would have to do it everywhere. Is there a better way to handle this king of problem?
Why I don't use the ReactJS API? Because when I built my React app, the API disappears: I'm using proxy.
var myModel = require('./models/myModel');
you can add by require here my model is in root directory inside model folder.
You could place the models in their own separate Node.js package, so they could be reused by both.
Please, refer to this: https://docs.npmjs.com/getting-started/creating-node-modules

Sails.js data missing on sails lift with waterline

I am using waterline orm which comes by default with sails.js. I recently recognized that my data just goes missing in my MySQL database when I do a sails lift. My model config is alter. Did anyone face similar issues? This is scary.
change your model config to 'safe' so it wont erase your data after you resetart your server..

Mongodb Association using koajs

I'm currently migrating my project form sails to koajs,
and i can't figure out how mongodb association is working in koajs.
I tried this code hoping that it will run, but it's hopeless.
properties.find({}).populate('user').sort('updatedAt DESC')
I'm currently using co-monk as a middleware. co-monk
Is there any middleware that can i use? So that i can use the mongodb association?
I tried searching at google but it gives me nothing.
Hopes that there is a solution.
Thanks guys.

Resources