我做了一个REST服务,我想发送一个带有JSON的参数:
console.time(`new ${number}`);
Readings.find({
sensor: 'Freezer'
}).sort('-time').limit(number).exec((err, readings) => {
if (err) {
console.log(err);
return;
}
readings.reverse();
// readings.forEach(reading => {
// console.log(new Date(reading.time).toLocaleString());
// });
console.timeEnd(`new ${number}`);
return;
});
console.time(`old ${number}`);
Readings.count({
sensor: 'Freezer'
}, (err, count) => {
if (err) {
console.log(err)
return;
}
Readings.find({
sensor: 'Freezer'
}).sort({'time':1}).skip(count - number).limit(number).exec((err, readings) => {
if (err) {
console.log(err);
return;
}
// readings.forEach(reading => {
// console.log(new Date(reading.time).toLocaleString());
// });
console.timeEnd(`old ${number}`);
return;
});
});
这是我对REST服务的代码:
{
"array":["hola","juan"]
"name": "hol"
}