Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A specific mongo query not working with query parameter. Cast Error encountered. #372

Open
abhishekvaid opened this issue Dec 12, 2017 · 0 comments

Comments

@abhishekvaid
Copy link

  • I have a collection which have document like these:

{ "_id" : ObjectId("599c05310252805c00f4f03d"), "facets" : [ { "id" : "culture", "values" : [ "hindu" ] }, { "id" : "occasion", "values" : [ "pre_wedding_shoot" ] }, { "id" : "photo_bucket", "values" : [ "wedding_photography" ] }, { "id" : "style_of_photography", "values" : [ "traditional" ] } ] }

  • Every document has a field facets which is an array of object. Each object in the array has two fields: id: <string> and values: [<string>]. My model file is attached with this ticket:
    seo_media_details.txt

  • Now when I try to query the REST API build with this plugin with following code

requestPromise({ uri: localhost:3000/api/v1/seo_media_details, qs: { query: JSON.stringify({ 'facets': { '$all': [ { 'id': "xxx", 'values': ['a', 'b', 'c'] } ] } }, resolveWithFullResponse: true }).then( ... )

  • but if change the value of values from an array to a single item. It works.

requestPromise({ uri: localhost:3000/api/v1/seo_media_details, qs: { query: JSON.stringify({ 'facets': { '$all': [ { 'id': "xxx", 'values': 'a'} ] } }, resolveWithFullResponse: true }).then( ... )

, it doesn't work, I get following error.
error.txt.

@abhishekvaid abhishekvaid changed the title A specific query isn't working. Tried on shell and it's working. A specific mongo query not working with query parameter. Cast Error encountered. Dec 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant