_node_resource_index

  1. services
    1. 7.3
    2. 7 node_resource.inc
    3. 6.2 node_resource.inc
    4. 6.3
Versions
6.3 _node_resource_index($page, $fields, $parameters, $page_size)
7 – 6.2 _node_resource_index($page = 0, $fields = array(), $parameters = array())
7.3 _node_resource_index($page, $fields, $parameters, $page_size)

Return an array of optionally paged nids baed on a set of criteria.

An example request might look like

http://domain/endpoint/node?fields=nid,vid&parameters[nid]=7&parameters[uid]=1

This would return an array of objects with only nid and vid defined, where nid = 7 and uid = 1.

@todo Evaluate the functionality here in general. Particularly around

  • Do we need fields at all? Should this just return full nodes?
  • Is there an easier syntax we can define which can make the urls for index requests more straightforward?

Parameters

$page Page number of results to return (in pages of 20).

$fields The fields you want returned.

$parameters An array containing fields and values used to build a sql WHERE clause indicating items to retrieve.

$page_size Integer number of items to be returned.

Return value

An array of node objects.

Code

resources/node_resource.inc, line 394

<?php
function _node_resource_index($page, $fields, $parameters, $page_size) {
  module_load_include('inc', 'services', 'services.module');
  $node_select = db_select('node', 't')
    ->addTag('node_access')
    ->orderBy('sticky', 'DESC')
    ->orderBy('created', 'DESC');

  services_resource_build_index_query($node_select, $page, $fields, $parameters, $page_size, 'node');

  if (!user_access('administer nodes')) {
    $node_select->condition('status', 1);
  }

  $results = services_resource_execute_index_query($node_select);

  return services_resource_build_index_list($results, 'node', 'nid');
}
?>