0

I am using RESTHeart to access a Mongo database. RESTHeart has a an API that is supposed to create a database, e.g.:

curl -X put http://localhost:8080/db1

Well, I was using a chrome browser-based REST client that happened to do the equivalent of the follow curl call, but I accidentally forgot to nuke the data portion. It contained the JSON {"e":"f"} for data.

curl -X put -H 'Content-Type: application/json' --data-raw '{"e":"f"}' http://localhost:8080/db2`

When I then tried to do a curl get, it returns a value with the key/value pair "e":"f" stuffed in there - which is not what I want.

$ curl  http://localhost:8080/db2

... { "_id" : "db2" , "e" : "f" , "_etag" : { "$oid" : "570f90601d956327e8df28c4"} , "_size" : 0 , "_total_pages" : 0 , "_returned" : 0}

Now, using the Mongo shell, I try to find this key/value pair using just about every Mongo shell command. But, I can't find it, nor can I remove it either. In fact, I can create a rather large Mongo database, then do that curl put, and I'm screwed, but it then adds the pair to my nice clean database.

Does anyone know how I can remove that strange key/value pair, either using Mongo shell, or the RESTHeart API - short of nuking the database and recreating it from scratch?! Thanks.

zx485
  • 28,498
  • 28
  • 50
  • 59
kaby76
  • 1,142
  • 1
  • 7
  • 10

1 Answers1

0

To remove the db property just update the db:

With PATCH:

PATCH /db {"$unset": {"e": null}}

Or with PUT

PUT /db {}

For more info look at the documentation reference sheet and representation format

Andrea Di Cesare
  • 1,125
  • 6
  • 11
  • I see you're referring to the SoftInstigate Wiki quite a lot. However, it seems to be a closed environment. Is it possible to get access? – Ralph Nov 26 '19 at 14:58
  • @Ralph this is an old answer. The documentation of RESTHeart has been moved to https://restheart.org/docs – Andrea Di Cesare Nov 28 '19 at 08:41