Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4828

Multiple where() properties when retrieving data via MIRAGE

$
0
0

@ChrizzDF wrote:

Hi guys,

I'm using Ember v2.50 & ember-cli-mirage v.0.1.x and I'm facing an annoying thing right now.

I'm trying to test (acceptance test) some filters that are affecting the result of a product list. I'm doing this with queryParams which are set to retrieve products from the the Mirage database, but if a filter isn't set which is undefined by default, I don't get any data back.

My Mirage part looks like this:

mirage/config.js

this.get('cool-products', function (db, request) {

  if (request.queryParams) {

    return {
      'cool-products': db['cool-products'].where({
        gender: request.queryParams.searchedGender,
        productCategory: request.queryParams.searchedProductCategory
      })
    };

  } else {

    return {
      'cool-products': db['cool-products']
    };

  }

});

This works only if both the searchedGender and the searchedProductCategory are set. I thought Mirage could handle undefined values and ignores the within the where clause.

Does someone have an idea how to fix this problem? I cannot believe that Mirage isn't able to deal with that, so maybe I'm doing anything wrong.

Thanks in advance! =)

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4828

Trending Articles