relation don't show the child always ??

23 views
Skip to first unread message

Eduardo Mazzucchelli

unread,
Jun 15, 2016, 4:35:59 PM6/15/16
to LoopbackJS
With where commented, works good !!!

    Modules.menu = function(idUser, cb) {

        //where: {idApp: 1},

        Modules.find(
            {
                include: {
                    relation: "Favourite",
                    scope: {
                        fields: ["id", "accessCount"],
                        where: {idUser: idUser}
                    }
                }
            }, function (err, instance) {
                response = instance;
                cb(null, response);
            });
    };


"status": [ { "id": 2, "idApp": 1, "identifier": 1001, "type": "tra", "name": "Master Small Wells", "description": "Así, en una página sobre puede haber una palabraAsí, en una página sobre puede haber una palabra.Así, en una página sobre puede haber una palabra.Así, en una página sobre puede haber una palabra..", "hidden": null, "Favourite": [ { "id": 291, "idModule": 2, "accessCount": 2 } ] },

With where doesn't commented, works wrong !!!

    Modules.menu = function(idUser, cb) {

        Modules.find({where: {idApp: 1}},
            {
                include: {
                    relation: "Favourite",
                    scope: {
                        fields: ["id", "accessCount"],
                        where: {idUser: idUser}
                    }
                }
            }, function (err, instance) {
                response = instance;
                cb(null, response);
            });
    };
{ "status": [ { "id": 2, "idApp": 1, "identifier": 1001, "type": "tra", "name": "Master Small Wells", "description": "Así, en una página sobre puede haber una palabraAsí, en una página sobre puede haber una palabra.Así, en una página sobre puede haber una palabra.Así, en una página sobre puede haber una palabra..", "hidden": null }, any ideas ??? regards
Eduardo

Ebrahim Pasbani

unread,
Jun 17, 2016, 12:20:45 PM6/17/16
to LoopbackJS
put all filters in one object

 Modules.menu = function(idUser, cb) {

       
 Modules.find({where: {idApp: 1},

           
                include
: {
                    relation
: "Favourite",
                    scope
: {
                        fields
: ["id", "accessCount"],
                       
where: {idUser: idUser}
                   
}
               
}
           
}, function (err, instance) {
                response
= instance;
                cb
(null, response);
           
});
   
};


Eduardo Mazzucchelli

unread,
Jun 19, 2016, 10:10:17 AM6/19/16
to loopb...@googlegroups.com
OK, 

If I put the detail condition up, in the header model, is OK ? 

I am going to try !!

Thank you Ebrahim


--
You received this message because you are subscribed to a topic in the Google Groups "LoopbackJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/loopbackjs/M5WaVISMGyE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to loopbackjs+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/loopbackjs/b108d843-e144-42e4-92f3-591df661fcd3%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages