简体   繁体   English

什么技术可以处理Node.JS中的JSON数据以将值与MongoDB进行比较?

[英]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. 我还有另一台服务器每秒向我的Node.JS服务器发出HTTP发布请求。 The posts are in the form of JSON data. 这些帖子采用JSON数据的形式。 My ultimate goal is to grab the data and look for the value in a MongoDB. 我的最终目标是获取数据并在MongoDB中寻找价值。 HERE is where I'm not sure how I should implement? 在这里我不确定应该如何执行? Node.js DATATables? Node.js DATATables? Just leave it in JSON and make calls every second to the DB? 只需将其保留在JSON中,并每秒对数据库进行调用? ClientSideDB like Loki.js? 像Loki.js这样的ClientSideDB? What ideas do you have? 你有什么想法?

Then, present the MongoDB data client side...But that's later. 然后,介绍MongoDB数据客户端...但是那是稍后的事情。

My current stack is a MEAN stack: Mongo Database, Express, Node.js server side, and AngularJS and Bootstrap Client Side. 我当前的堆栈是MEAN堆栈:Mongo数据库,Express,Node.js服务器端以及AngularJS和Bootstrap客户端端。

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. 如果您想继续使用Node.js,MongoDb,那么我建议您应该开始使用Sails.js之类的后端框架。 Its build on top of Express.js and has many handy features. 它基于Express.js构建,并具有许多方便的功能。 Its based on MVC pattern but you can use angular for client side also. 它基于MVC模式,但您也可以在客户端使用angular。

Get started with Sails.js 开始使用Sails.js

Sails.js Documentation Sails.js文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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