library(jsonlite)
library(mongolite)
library(lubridate)
#' @post /predict
predict= function(x, y)
{
mongodatas <- mongo(collection='db12', url='mongodb://ganesh123:[email protected]:63137/ganesh123')
naan <- mongodatas$find(query= '{ "data_time": {"$gte": "x" , "$lt": "y"} }',
fields= '{"_id": 0, "data_time": 1, "id": 1, "sensor3": 1 }',
sort= '{"data_time": 1}' ,
limit=5000
)
return(naan)
}
The above code is my R Api done using plumber and done using POST method and this works if the below postman input x
and y
is given as static in the find query
naan <- mongodatas$find(query= '{ "data_time": {"$gte": **"x"** , "$lt": **"y"**} }', "
{
"x": "2018-07-25 17:02:17.249591",
"y": "2018-07-25 17:02:17.674801"
}
The above code is my input to R Api This is input from postman link http://localhost:3000/predict
"id": "1",
"data_time": "2018-07-25 17:02:17.249591",
"sensor3": "4.12"
This is my database structure. The query cannot process the input data.