0

I want to send ID dynamically to the following line.

out <- m$find('{"CreatedBy":"5ab0abb017aac60f443d517b"}')

Here the string I want to send dynamically is 5ab0abb017aac60f443d517b

So basically a function that would read take the ID as input param and put it inside of it.

Something like.

fetchdat <- function(x)
{

  out <- m$find('{"CreatedBy":"5ab0abb017aac60f443d517b"}')


}

I might want to call it like fetchdat("id")

Someone suggested R -How to pass value in mongolite Query

fetchdat <- function(x)
{

  out <- m$find(paste0('{"CreatedBy" :', x ,' }'))
  return(out)

}

I run into following error

Error: Invalid JSON object: {"CreatedBy" :5ab0abb017aac60f443d517b }

Rana Usman
  • 1,031
  • 7
  • 21

0 Answers0