Skip to content

Commit f2640ee

Browse files
author
antonio.gallo
committed
updated FAQ to introduce the resolution of the problem for id and etag with $oid attribute
1 parent 0a213d1 commit f2640ee

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ You can also **check out [a video introduction of a talk I gave at Devoxx France
7676
- [Can it be used in $routeProvider.resolve?](#can-it-be-used-in-routeproviderresolve)
7777
- [My response is actually wrapped with some metadata. How do I get the data in that case?](#my-response-is-actually-wrapped-with-some-metadata-how-do-i-get-the-data-in-that-case)
7878
- [I use Mongo and the ID of the elements is _id not id as the default. Therefore requests are sent to undefined routes](#i-use-mongo-and-the-id-of-the-elements-is-_id-not-id-as-the-default-therefore-requests-are-sent-to-undefined-routes)
79+
- [I use Mongo and the ID of the elements is `_id` and is encapsulated inside the $oid attribute](#i-use-mongo-and-the-etag-of-the-elements-is-_etag-and-is-encapsulated-inside-the-oid-attribute)
80+
- [I use Mongo and the ETag of the elements is `_etag` and is encapsulated inside the $oid attribute](#i-use-mongo-and-the-etag-of-the-elements-is-_etag-and-is-encapsulated-inside-the-oid-attribute)
7981
- [What if each of my models has a different ID name like CustomerID for Customer](#what-if-each-of-my-models-has-a-different-id-name-like-customerid-for-customer)
8082
- [How do I handle CRUD operations in a List returned by Restangular?](#how-do-i-handle-crud-operations-in-a-list-returned-by-restangular)
8183
- [When I set baseUrl with a port, it's stripped out.](#when-i-set-baseurl-with-a-port-its-stripped-out)
@@ -1151,6 +1153,26 @@ RestangularProvider.setRestangularFields({
11511153
});
11521154
````
11531155

1156+
#### **I use Mongo and the ID of the elements is `_id` and is encapsulated inside the $oid attribute**
1157+
1158+
What you need to do is to configure the `RestangularFields` and set the `id` field to `_id.$oid`. Let's see how:
1159+
1160+
````javascript
1161+
RestangularProvider.setRestangularFields({
1162+
id: "_id.$oid"
1163+
});
1164+
````
1165+
1166+
#### **I use Mongo and the ETag of the elements is `_etag` and is encapsulated inside the $oid attribute**
1167+
1168+
What you need to do is to configure the `RestangularFields` and set the `etag` field to `_etag.$oid`. Let's see how:
1169+
1170+
````javascript
1171+
RestangularProvider.setRestangularFields({
1172+
etag: "_etag.$oid"
1173+
});
1174+
````
1175+
11541176
#### **What if each of my models has a different ID name like CustomerID for Customer**
11551177

11561178
In some cases, people have different ID name for each entity. For example, they have CustomerID for customer and EquipmentID for Equipment. If that's the case, you can override Restangular's getIdFromElem. For that, you need to do:

0 commit comments

Comments
 (0)