mercredi 8 juillet 2015

Loopbackjs - Check if property is instance of type

I need to check if a model property is of some type in order to do some processing only to those properties.

So far I have this:

Business.afterRemote('find', function (ctx, businesses, next) {
    var lang = ctx.req.headers.language || 'es';

    // This always prints false, even when the property is defined as an array of
    // MyModel objects.
    console.log(ctx.result[0] instanceof app.models.MyModel)
    next();
});





Aucun commentaire:

Enregistrer un commentaire