My web API controller is built with MongoDb as the backend.
public class NodesRestController : ApiController
{
private INodeService _nodeService;
public NodesRestController(INodeService nodeService)
{
_nodeService = nodeService;
}
[EnableQuery()]
public IQueryable<Node> Get()
{
return _nodeService.GetAllNodes().AsQueryable();
}
[EnableQuery()]
public Node Get(Guid id)
{
return _nodeService.GetNodeById(id);
}
}
Within my Angular application, the resource setup is as follows:
(function() {
'use strict';
var nodeServiceRoot = '/api/NodesRest/:id';
angular.module('common.service')
.factory("nodeResource", ["$resource", "appSettings", nodeResource])
function nodeResource($resource, appSettings) {
return $resource(appSettings.serverPath + nodeServiceRoot, {
id: '@id'
}, {
"update": {
method: "PUT"
}
});
}}());
The Nodes Collection contains multiple instances like the one below:
{
"_id" : LUUID("982d248a-ef2a-f94c-be93-96ff67ca1d3f"),
"Name" : "RTR1",
"IP" : "1.2.221.121",
"NodeGroup" : {
"_id" : LUUID("36a38db3-830c-4a45-8b9c-63b16394f985"),
"Name" : "Group One"
}}
I am attempting to retrieve nodes where NodeGroup.Name is "Group One", but I am getting back all nodes.
var nodesInNodeGroup = nodeResource.query({ 'NodeGroup/Name': vm.CurrJob.NodeGroup.Name});
nodesInNodeGroup.$promise.then(function (response) {
nodesInNodeGroup = response;
});
vm.CurrJob.NodeGroup.Name = 'Group One'
Any assistance would be appreciated.