Skip to content

Default value for empty array #2

@Prinzhorn

Description

@Prinzhorn

Thanks for creating screener, I'm using it for our mobile API.

I have an offer object and my filter looks like this

module.exports = {
    _id: true,
    title: true,
    body: true,
    location: true,
    images: [require('../image')]
};

and image looks like

var models = require('models');

module.exports = function(object) {
    return models.Image.getUrl(object);
};

It's working perfectly and transforms the array of image _ids into an array of Strings (the URLs of the images).

Now the thing is I'd like to have at least one image inside the array. That means if the offer object does not have any images (empty array), then I want to react and fill it with the URL of the default image.

It would be great if there's a way to do this with screener as I'd like to keep the logic away from the controller.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions