w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How to retrieve the ID as part of an index with AngularJS and RavenDB?

Well to the first part of your question an index does not change what the results look like only how you query the data. So creating an index with an "id" field would not do what you want. If you want to change the results you need to use a transformer. So in your case you would create a transformer like:

from product in results
select new
   id = product.Id,
   name = product.Name,
   category = product.Category,
   description = product.Description,
   price = product.Price

than you would need to tie the transformer to your index. So your url would look like this:


Hope that helps.

As an alternative suggestion if you didn't want use the transformer. In angular you could do something like this:

   <tr ng-repeat="product in products">
      <!-- other columns -->

Then on your $scope:

$scope.getId = function(product){
    return product["@metadata"]["@id"];

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.