简体   繁体   中英

What technology to Process JSON data in Node.JS to compare values to MongoDB?

Good evening,

I'm having a tough time figuring out what technology I should pair with my current stack. I don't necessarily need to know how to implement it, however if you're happy to oblige, I'll be happy to accept it :).

What I'm trying to achieve? I've got another server making HTTP post requests every second to my Node.JS server. The posts are in the form of JSON data. My ultimate goal is to grab the data and look for the value in a MongoDB. HERE is where I'm not sure how I should implement? Node.js DATATables? Just leave it in JSON and make calls every second to the DB? ClientSideDB like Loki.js? What ideas do you have?

Then, present the MongoDB data client side...But that's later.

My current stack is a MEAN stack: Mongo Database, Express, Node.js server side, and AngularJS and Bootstrap Client Side.

Here's some code even though that's not really what this is about:

var express    = require('express');  
var app        = express();  
var bodyParser = require('body-parser');

app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());

var router = express.Router(); 

router.post('/', function(req, res) { 
    console.log(req.body.results);     // Just returning JSON results to console for now 
    res.end();
});

app.use('/api', router);

app.listen(port);
console.log('Magic happens on port ' + port);

If you want to proceed with Node.js, MongoDb then i'll suggest you should start using a backend framework like sails.js. Its build on top of Express.js and has many handy features. Its based on MVC pattern but you can use angular for client side also.

Get started with Sails.js

Sails.js Documentation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM