http-api-mock
http-api-mock copied to clipboard
Can't setup the config-persist-path to mongo
Hello! Thank you for this mock server.
I've successfully worked with mock server using file persistency. But, now I have some problems with a large size of files and I need to move my mock data to mongo.
But when I run server with 'config-persist-path' with mongo URL, finally in root directory i got folder named as 'mongo:'. When i start debugging, i see the following condition doesn't run if strings.Index(persistPath, "mongodb://") < 0 {
.
Here how I execute server:
http-api-mock -config-persist-path mongodb://localhost/test
is it correct?
Sorry for my english :)
Seems like there was a bug when reading the persist path which I just fixed in the master branch. Can you please try again?
@vtrifonov, sorry for late response. Seems like everything is works fine, thank you!
One more question, how I should get the value of entity from collection?
{ "description": "Gets info about services", "request":{ "method":"GET", "path":"/v1/getAllServices.json" }, "persist": { "entity": "services/ObjectId('5b35c7a1c0c372304f8f0662')" }, "response": { "statusCode": 200, "headers": { "Content-Type": [ "application/json" ] }, "body": "{{ persist.entity.content }}" } }
After this query, mongo returns nothing. After read mongo logs i see this:
{ find: "services", filter: { _id: "ObjectId('5b35c7a1c0c372304f8f0662')" }
,
but query should be without quotes in filter, if I execute query without quotes, everything is ok.
Can u show me example how to define my persist file?