Using a MEAN stack (fairly new to all of these) please pardon me if I'm way 
off ...

In mongo I have a collection of People

People have children so People have a single 'ParentId' property

{
   _id: ObjectId,
   ShortId: 1
   FirstName: 'Joe',
   LastName: 'Bob'
   ParentId: null
},
{
   _id: ObjectId,
   ShortId: 2
   FirstName: 'Jim',
   LastName: 'Bob'
   ParentId: 1
}
,
{
   _id: ObjectId,
   ShortId: 3
   FirstName: 'Billy',
   LastName: 'Bob'
   ParentId: 1
}

So I'm using Angular resource (angular-resource) for calling  "People" 
either a list of or single people

angular.module('app').factory('PeopleService',function($resource){
    var PeopleResource = $resource('/api/people/:_id', {_id:"@id"}, {
        update: {method:'PUT', isArray: false}
    });

    return PeopleResource;

});


So now I want to select all 'children' of a parent....this is not another 
resource correct? so it is a service?

angular.module('app').service('PeopleService', function($http, $q){
   this.getChildren = function(parentId){
      var deferred = $q.defer();
      deferred.resolve($http.get("/api/people/" + parentId + "/children"));
   }
})

should I just bail on the 'angular-resource' and just make it all a service?

It seems like using the resource i will end up with a 'resource' (meaning a 
new file) for every call to my api when I can just build a 'people' service 
and add all of my api calls there...

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to angular+unsubscr...@googlegroups.com.
To post to this group, send email to angular@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to